W3cubDocs

/Matplotlib 3.1

matplotlib.animation.AbstractMovieWriter

class matplotlib.animation.AbstractMovieWriter [source]

Abstract base class for writing movies. Fundamentally, what a MovieWriter does is provide is a way to grab frames by calling grab_frame().

setup() is called to start the process and finish() is called afterwards.

This class is set up to provide for writing movie frame data to a pipe. saving() is provided as a context manager to facilitate this process as:

with moviewriter.saving(fig, outfile='myfile.mp4', dpi=100):
    # Iterate over frames
    moviewriter.grab_frame(**savefig_kwargs)

The use of the context manager ensures that setup() and finish() are performed as necessary.

An instance of a concrete subclass of this class can be given as the writer argument of Animation.save().

__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

finish(self) Finish any processing for writing the movie.
grab_frame(self, \*\*savefig_kwargs) Grab the image information from the figure and save as a movie frame.
saving(self, fig, outfile, dpi, \*args, ...) Context manager to facilitate writing the movie file.
setup(self, fig, outfile[, dpi]) Perform setup for writing the movie file.
finish(self) [source]

Finish any processing for writing the movie.

grab_frame(self, **savefig_kwargs) [source]

Grab the image information from the figure and save as a movie frame.

All keyword arguments in savefig_kwargs are passed on to the savefig command that saves the figure.

saving(self, fig, outfile, dpi, *args, **kwargs) [source]

Context manager to facilitate writing the movie file.

*args, **kw are any parameters that should be passed to setup.

setup(self, fig, outfile, dpi=None) [source]

Perform setup for writing the movie file.

Parameters:
fig : matplotlib.figure.Figure instance

The figure object that contains the information for frames

outfile : string

The filename of the resulting movie file

dpi : int, optional

The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. Default is fig.dpi.

© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.animation.AbstractMovieWriter.html