Animation and imshow

I'm trying to figure out how to do animated graphics in pylab using
imshow, so I made this little 'hello world' equivalent showing a
moving square over two frames.
Problem is I have to call draw twice to refresh the image. Anyone can
explain why this is so (and how to do this more elegantly)? This is
the code:

from pylab import *
from numpy import *

ion()
hold(False)

frame1 = zeros((200, 200))
frame1[20:40, 20:40] = 255

frame2 = zeros((200, 200))
frame2[20:40, 30:50] = 255

m = imshow(frame1)
draw()               # shows frame1
m.set_data(frame2)
draw()               # still shows frame1!!!
draw()               # and now it shows frame2!??

--

-- 
Alex Borghgraef

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
(Continue reading)

John Hunter | 9 Oct 14:47
Gravatar

Re: Animation and imshow

On Tue, Oct 7, 2008 at 8:10 AM, Alexander Borghgraef
<alexander.borghgraef.rma@...> wrote:
> I'm trying to figure out how to do animated graphics in pylab using
> imshow, so I made this little 'hello world' equivalent showing a
> moving square over two frames.
> Problem is I have to call draw twice to refresh the image. Anyone can
> explain why this is so (and how to do this more elegantly)? This is
> the code:

I do not see this problem using svn HEAD (the first draw after setting
the frame2 data shows the frame2 image).

There are a couple examples showing how to do animation for images in
the mpl examples dir -- see attached
Attachment (dynamic_image_gtkagg.py): text/x-python-script, 796 bytes
Attachment (dynamic_image_wxagg2.py): text/x-python-script, 3037 bytes
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Gmane