Python Forum
Matplotlib question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matplotlib question
#1
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 ?!?!?!?!
Reply
#2
Have you posted your code?
Nobody can guess what's wrong!
Reply
#3
(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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020