Python Forum

Full Version: Matplotlib question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
where can i ask a question about matplotlib ive been asking everywhere and nothing but silence. i have written a program in it and it needs to be modified to work right and i cant find any help. i just want live graph that reads a text file and dont get sluggish and free up when the for loop tries to read a big text file ?!?!?!?!
Have you posted your code?
Nobody can guess what's wrong!
(Mar-29-2018, 06:19 AM)Barrowman Wrote: [ -> ]Have you posted your code?
Nobody can guess what's wrong!

i minimized the code to do only what i talked about. this reads the txt file and displays it on the graph. problem is i think it too much to draw the graph all the time and i cant imagine how long it would take to load a 50mb text file when it cant open a 20kb text file within 15 seconds,

import numpy as np
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111)
plt.ion()

fig.show()
fig.canvas.draw()


pullData = open("Log.txt","r").read()
dataList = pullData.split('\n')
xList = []
yList = []
for eachLine in dataList:
    if len(eachLine) > 1:
        x, y = eachLine.split()
        yList.append(float(y))    #convert to float
        xList.append(x)           #Time
    ax.clear()
    ax.plot(xList, yList)
fig.canvas.draw()

is there a way to instead of re-drawing 1000 lines on the graph every time it draws the screen instead make it remember the last point and only draw new ones? i think that would totally solve the problem but i don't know if or how that's possible