Skip to content Skip to sidebar Skip to footer

Updating A Plot In Python In Real Time

I have a python code in which I calculate a quantity for a large number of values of a parameter and then plot the quantity as a function of a parameter. Here is an example t = np.

Solution 1:

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)

ripped from the post i put in the comments ...


Post a Comment for "Updating A Plot In Python In Real Time"