Matplotlib-users Digest, Vol 29, Issue 19

Message: 8
Date: Wed, 08 Oct 2008 17:05:46 -0400
From: Alan G Isaac <aisaac@...310...>
Subject: Re: [Matplotlib-users] Animation and imshow
To: Matplotlib Users <matplotlib-users@lists.sourceforge.net>
Message-ID: <48ED20AA.90602@...310...>
Content-Type: text/plain; charset=UTF-8; format=flowed

> loop through the data and call clf():

if the confusion is over my signature, i still sign using a gpg key
registered to a different email account

The clf call seems quite wrong:
it flashes horribly and I get good
behavior without it (once I add
a call to sleep). What am I
missing?

afaik it doesn't look like there's anything missing

if anything there is some superfluous code:
fig1 = plt.figure(1)
ax1 = fig1.gca()
and the animated=True kwarg

I don't what is optimum, matplotlib has always been a bit hackish for
animation i think

best

Michael Nandris

···

On Thu, 2008-10-09 at 03:15 +0000, matplotlib-users-request@lists.sourceforge.net wrote:

On 10/7/2008 6:23 PM Michael apparently wrote:

Alan Isaac

PS The following almost works (i.e., works,
but then exits with an error).

import matplotlib.pyplot as plt
from time import sleep
from numpy import zeros

plt.ion()
plt.hold(False)

data = list()
slices = list()
for i in range(5):
     frame = zeros( (200,200) )
     frame[20:40,10*i:10*i+20] = 255
     data.append(frame)

fig1 = plt.figure(1)
ax1 = fig1.gca()
for frame in data:
     plt.imshow(frame, axes=ax1, animated=True)
     sleep(0.2)

--
"When you think of the long and gloomy history of man, you will find far
more hideous crimes have been committed in the name of obedience than
have been committed in the name of rebellion". C.P.Snow,
"Either-Or" (1961)

Calling cla or clf in the animation loop is probably always a bad
idea, because of the flashing you have noticed. Trying to use a simple
python loop called from the main level doesn't play nicely with the
GUI event loop and will fail in most cases.

I have written all of the animation examples in the
matplotlib/examples/animation directory to avoid a main level python
loop. Ideally, you should use your GUI idle handler to trigger the
animation update.

  matplotlib download | SourceForge.net

I have spent some time trying to abstract this across the different
GUIs we support to make this easier on users, but have been stymied...

JDH

···

On Thu, Oct 9, 2008 at 5:12 AM, Michael <mnandris@...2197...> wrote:

I don't what is optimum, matplotlib has always been a bit hackish for
animation i think