Animated artists not present in savefigged files

Hi list,

I am using animated artists to generate an animation, where I save each step in the anmantion as a png using the savefig method of the figure instance

after drawing the animated artists on a cached background and after fig.canvas.blit.

What I see on screen are the updated animated artists being drawn, but only the cached background with subplots and axes and grid is being stored in the savefig commands

called after the last blit.

Why is only the background saved.?

I am using matplotlib ver. 0.99.1 and the ‘TkAgg’ backend on a Win XP PC.

Thanks in advance,

Kim

The animated property tells the figure to not draw the artist on a
call to figure.draw, which is wha savefig calls. This enables you to
draw the background (everything but the animated artists) with a call
to figure.canvas.draw, and then selectively draw your animated artists
when you want. It does pose a problem for saving.

The best approach is to turn off the animated property right before
saving, and turn it back on as needed. Something like

artists = fig.get_children()

animated = dict()
for artist in artists:
    animated[artist] = artist.get_animated()
    artist.set_animated(False)

fig.savefig('myfig.png')

for artist in artists:
    artist.set_animated(animated[artist])

Also, Ryan May has been working on a nice framework for animation that may help,

http://github.com/dopplershift/Animation

JDH

···

On Mon, Aug 23, 2010 at 7:59 AM, Kim Hansen <slaunger@...287...> wrote:

Hi list,

I am using animated artists to generate an animation, where I save each step
in the anmantion as a png using the savefig method of the figure instance
after drawing the animated artists on a cached background and after
fig.canvas.blit.

What I see on screen are the updated animated artists being drawn, but only
the cached background with subplots and axes and grid is being stored in the
savefig commands
called after the last blit.

Why is only the background saved.?

What I use to create animations is plainly:

savefig(head+str(filecode).zfill(digits)+format, dpi=205)
plt.clf()
filecode+=1

where filecode is the name, digits an int and format usually .png.

clf() is important in order to prevent memory leaks, because otherwise
mpl stores all the figures one in top of the other, consuming a lot of
resources once you have a several images.

To stick all of them together, I use a video editor.

···

On Mon, Aug 23, 2010 at 2:59 PM, Kim Hansen <slaunger@...287...> wrote:

Hi list,

I am using animated artists to generate an animation, where I save each step
in the anmantion as a png using the savefig method of the figure instance
after drawing the animated artists on a cached background and after
fig.canvas.blit.

What I see on screen are the updated animated artists being drawn, but only
the cached background with subplots and axes and grid is being stored in the
savefig commands
called after the last blit.

Why is only the background saved.?

I am using matplotlib ver. 0.99.1 and the 'TkAgg' backend on a Win XP PC.

Thanks in advance,
Kim
------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users