On Mon, Sep 20, 2010 at 8:14 PM, Brian Blais <bbl...@bryant.edu> wrote: > sure, but that take more effort, and I don't really care about a slow down, > because most of my time is spent in the busy loop. I do > care about it displaying *at all*, which is the problem. I am familiar with > the efficient way of animating, but for most things I want to > focus on the computation and then display here and there, so I want the > shortest, clearest plotting code without any optimizations. if I > call plot commands, and then a draw, I expect it to actually pause right > there until it is done drawing, and then continue...it's not doing > that.
It might be more effort, but what you're doing now plays havoc with GUI event loops. Now, granted, until EPD upgrades to Matplotlib 1.0.0 this won't work for you (unless you're willing to install your own), but this is how IMHO is best to approach this problem: import matplotlib.pyplot as plt import numpy as np import sys def dot(): sys.stdout.write('.') sys.stdout.flush() def busy_loop(): for i in range(1000): r = np.random.rand(100,100) return r def update_plot(): update_plot.count += 1 r = busy_loop() plt.clf() plt.imshow(r, interpolation='nearest', cmap=plt.get_cmap('gray')) plt.draw() dot() # Automatically stops after 10 return update_plot.count < 10 update_plot.count = 0 fig = plt.figure() # Creates a new timer that fires every 250 ms timer = fig.canvas.new_timer(interval=250) timer.add_callback(update_plot) timer.start() plt.show() This, to me, isn't any more complex than your original (the most complex part comes from getting it to stop after a fixed number of iterations). The benefit is that the timed updates integrate into the GUI event loop and don't fight it. The other benefit is that this works with any of the interactive backends and you don't end up debugging weird draw problems. Even when I've gotten your style of animation to work in the past, I've still had problems where resizing the figure, etc. don't work. Hope this helps (at least in the future), Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users