Interactive Replotting

Hi,

I'm trying to get matplotlib to replot a pcolor image as data in a file is updated. What's the proper way to do this? The best approach I could come up with is as follows:

import threading, time
import numpy as N
import matplotlib.pyplot as P

def update_plot(*args):
     ax = args[0]
     while True:
         data = N.random.rand(10,10)
         if ax.collections:
             del ax.collections[0]
         ax.pcolor(data)
         print 'drawing'
         P.draw()
         time.sleep(1)

P.ion()
f = P.figure()
ax = f.add_subplot(1,1,1)
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')

t = threading.Thread(name='Plot', target=update_plot, args=(ax,))
t.start()
P.show()

Can anyone point me in the right direction?

Thanks,

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Ryan May wrote:

Hi,

I'm trying to get matplotlib to replot a pcolor image as data in a file is updated. What's the proper way to do this? The best approach I could come up with is as follows:

Ok, I hadn't noticed the dynamic_image_gtkagg.py example before. I'm pretty sure this will do what I need. Anyone have any pitfalls or gotcha's with this method?

Thanks,

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma