|
From: David H. <dh...@gm...> - 2013-03-11 14:34:20
|
You likely need to "show()" the canvas. I usually do this by calling
"fig.canvas.show()" before the for loop.
Since you are using a Qt4 backend the canvas used by the figure is a
QWidget, the basic component of a Qt4 GUI. I don't know if there is a
more matplotlib specific way of doing this, but when dealing with a
larger system this is how I do it.
I would also add a sleep ("from time import sleep") of a couple seconds
for testing to make sure you are getting through the entire for loop
before you can see it.
Please CC in any replies, thanks.
-Dave
On 3/11/13 8:58 AM, ndb...@gm... wrote:
> I want to update a plot in real time. I did some goog search, and saw various
> answers. Trouble is, they aren't working.
>
> Here's a typical example:
>
> import matplotlib.pyplot as plt
> import numpy as np
> fig=plt.figure()
> plt.axis([0,1000,0,1])
>
> i=0
> x=list()
> y=list()
>
> while i <1000:
> temp_y=np.random.random()
> x.append(i)
> y.append(temp_y)
> plt.scatter(i,temp_y)
> i+=1
> plt.draw()
>
> If I run this, it draws nothing.
>
> This is my matplotlibrc:
> backend : Qt4Agg
> mathtext.fontset: stix
|