Issue
To give you a sense of what I'm looking for, it looks like this:
Up until now I have used matplotlib for all my plotting, and timing hasn't been critical (it's been done in postprocessing).
I'm wondering if there is a lighter weight way to plot other than shifting my data to the left and redrawing the entire plot.
Solution
Have a look at the Matplotlib Animations Examples. The main trick is to not completely redraw the graph but rather use the OO interface of matplotlib and set the x/ydata of the plot-line you created. If you've integrated your plot with some GUI, e.g., GTK, then definitely do it like proposed in the respective section of the plot, otherwise you might interfere with the event-loop of your GUI toolkit.
For reference, if the link ever dies:
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
Answered By - Thorsten Kranz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.