How to redraw an image using ppton matplotlib?

What I'm trying to do seems pretty simple, but I have time trying to get it to work. I'm just trying to make an image using imshow and then re-draw it as new data arrives.

I started with this:

fig = figure() ax = plt.axes(xlim=(0,200),ylim=(0,200)) myimg = ax.imshow(zeros((200,200),float)) 

Then I guess I can call set_data like this to update the image:

 myimg.set_data(newdata) 

I tried many other things, for example, I called ax.imshow(newdata) instead, or I tried to use figure.show() after set_data() .

+8
python matplotlib imshow
source share
1 answer

You can simply call figure.canvas.draw () every time you add something new to the figure. This will update the schedule.

 from matplotlib import pyplot as plt f = plt.figure() ax = f.gca() f.show() for i in range(10): ax.plot(i, i, 'ko') f.canvas.draw() raw_input('pause : press any key ...') f.close() 
+10
source share

All Articles