Book Image

Interactive Applications using Matplotlib

Book Image

Interactive Applications using Matplotlib

Overview of this book

Table of Contents (12 chapters)

The animation module


Now that we've had a crash course in animations for Matplotlib, let's take a step back and get to know the animation module. There is the base Animation class and three subclasses, namely, TimedAnimation, FuncAnimation, and ArtistAnimation. These classes handle all of the work necessary to initiate the animation upon call to show() and update the figure window with a new draw at the appropriate intervals. They also provide the interface to save your animation, hiding away many of the ugliness one might find when manually composing their own animation.

The most simple animation class is ArtistAnimation. You first perform all of the plotting, appending the artists of each frame into a list of lists. Each sublist represents all of the artists that should be visible for a given frame. The length of the list provided to the ArtistAnimation class is the number of frames the animation will have. When rendering, the ArtistAnimation class will modify the appropriate artists' visibility...