matplotlib 3.5.1

NotesParameters
save(self, filename, writer=None, fps=None, dpi=None, codec=None, bitrate=None, extra_args=None, metadata=None, extra_anim=None, savefig_kwargs=None, *, progress_callback=None)

Notes

fps, codec, bitrate, extra_args and metadata are used to construct a .MovieWriter instance and can only be passed if writer is a string. If they are passed as non-None and writer is a .MovieWriter , a :None:None:`RuntimeError` will be raised.

Parameters

filename : str

The output filename, e.g., mymovie.mp4 .

writer : `MovieWriter` or str, default: :rc:`animation.writer`

A MovieWriter instance to use or a key that identifies a class to use, such as 'ffmpeg'.

fps : int, optional

Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.

dpi : float, default: :rc:`savefig.dpi`

Controls the dots per inch for the movie frames. Together with the figure's size in inches, this controls the size of the movie.

codec : str, default: :rc:`animation.codec`.

The video codec to use. Not all codecs are supported by a given MovieWriter .

bitrate : int, default: :rc:`animation.bitrate`

The bitrate of the movie, in kilobits per second. Higher values means higher quality movies, but increase the file size. A value of -1 lets the underlying movie encoder select the bitrate.

extra_args : list of str or None, optional

Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use animation.[name-of-encoder]_args for the builtin writers.

metadata : dict[str, str], default: {}

Dictionary of keys and values for metadata to include in the output file. Some keys that may be of use include: title, artist, genre, subject, copyright, srcform, comment.

extra_anim : list, default: []

Additional Animation objects that should be included in the saved movie file. These need to be from the same matplotlib.figure.Figure instance. Also, animation frames will just be simply combined, so there should be a 1:1 correspondence between the frames from the different animations.

savefig_kwargs : dict, default: {}

Keyword arguments passed to each ~.Figure.savefig call used to save the individual frames.

progress_callback : function, optional

A callback function that will be called for every frame to notify the saving progress. It must have the signature :

def func(current_frame: int, total_frames: int) -> Any

where current_frame is the current frame number and total_frames is the total number of frames to be saved. total_frames is set to None, if the total number of frames can not be determined. Return values may exist but are ignored.

Example code to write the progress to stdout:

progress_callback =                    lambda i, n: print(f'Saving frame {i} of {n}')

Save the animation as a movie file by drawing every frame.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/animation.py#924
type: <class 'function'>
Commit: