psihodelia
psihodelia

Reputation: 30492

Python - animation with matplotlib.pyplot

How can one create animated diagrams using popular matplotlib library? I am particularly interested in animated gifs.

Upvotes: 22

Views: 36654

Answers (2)

Mark
Mark

Reputation: 108522

The matplotlib docs provide an entire section of examples on animation (see this scipy tutorial also). Most, however, involve using the various GUI widget backends. There is one in there, "movie demo", that shows how to produce an avi of a series of PNGS.

To produce animated GIFs, I think your options are pretty limited. Last I checked, PIL didn't support them. You could however generate a series of PNGs using pyplot's savefig and then stitch them together using a call to ImageMagick or mencoder.

Upvotes: 23

Unapiedra
Unapiedra

Reputation: 16197

Update in 2017

Matplotlib has the animation module, and in it you find the ImageMagickFileWriter class. It is advertised as "File-based animated gif writer."

Documentation: http://matplotlib.org/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.html#matplotlib.animation.ImageMagickFileWriter

Upvotes: 6

Related Questions