matplotlib

Table Of Contents

Previous topic

afm (Adobe Font Metrics interface)

Next topic

artists

This Page

animation

matplotlib.animation

class matplotlib.animation.Animation(fig, event_source=None, blit=False)

Bases: object

This class wraps the creation of an animation using matplotlib. It is only a base class which should be subclassed to provide needed behavior.

fig is the figure object that is used to get draw, resize, and any other needed events.

event_source is a class that can run a callback when desired events are generated, as well as be stopped and started. Examples include timers (see TimedAnimation) and file system notifications.

blit is a boolean that controls whether blitting is used to optimize drawing.

ffmpeg_cmd(fname, fps, codec, frame_prefix)
mencoder_cmd(fname, fps, codec, frame_prefix)
new_frame_seq()
Creates a new sequence of frame information.
new_saved_frame_seq()
Creates a new sequence of saved/cached frame information.
save(filename, fps=5, codec='mpeg4', clear_temp=True, frame_prefix='_tmp')

Saves a movie file by drawing every frame.

filename is the output filename, eg mymovie.mp4

fps is the frames per second in the movie

codec is the codec to be used,if it is supported by the output method.

clear_temp specifies whether the temporary image files should be deleted.

frame_prefix gives the prefix that should be used for individual image files. This prefix will have a frame number (i.e. 0001) appended when saving individual frames.

class matplotlib.animation.ArtistAnimation(fig, artists, *args, **kwargs)

Bases: matplotlib.animation.TimedAnimation

Before calling this function, all plotting should have taken place and the relevant artists saved.

frame_info is a list, with each list entry a collection of artists that represent what needs to be enabled on each frame. These will be disabled for other frames.

class matplotlib.animation.FuncAnimation(fig, func, frames=None, init_func=None, fargs=None, save_count=None, **kwargs)

Bases: matplotlib.animation.TimedAnimation

Makes an animation by repeatedly calling a function func, passing in (optional) arguments in fargs.

frames can be a generator, an iterable, or a number of frames.

init_func is a function used to draw a clear frame. If not given, the results of drawing from the first item in the frames sequence will be used.

new_frame_seq()
new_saved_frame_seq()
class matplotlib.animation.TimedAnimation(fig, interval=200, repeat_delay=None, repeat=True, event_source=None, *args, **kwargs)

Bases: matplotlib.animation.Animation

Animation subclass that supports time-based animation, drawing a new frame every interval milliseconds.

repeat controls whether the animation should repeat when the sequence of frames is completed.

repeat_delay optionally adds a delay in milliseconds before repeating the animation.