I'm plotting a line using matplotlib and would like to update my line data as soon as new values are generated. However, once in the loop, no window appears. Even though the printed line indicates the loop is running.
Here's my code:
def inteprolate(u,X):
...
return XX
# generate initial data
XX = inteprolate(u,X)
#initial plot
xdata = XX[:,0]
ydata = XX[:,1]
ax=plt.axes()
line, = plt.plot(xdata,ydata)
# If this is in, The plot works the first time, and then pauses
# until the window is closed.
# plt.show()
# get new values and re-plot
while True:
print "!"
XX = inteprolate(u,XX)
line.set_xdata(XX[:,0])
line.set_ydata(XX[:,1])
plt.draw() # no window
How do I update my plot in real-time when the plt.show()
is blocking and plt.draw
doesn't update/display the window?