| [ Web Proxy ] |
| Viewing: https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.Animation.html | [Back] [Original] |
Section Navigation
matplotlibmatplotlib.animationmatplotlib.artistmatplotlib.axesmatplotlib.axismatplotlib.backend_basesmatplotlib.backend_managersmatplotlib.backend_toolsmatplotlib.backendsmatplotlib.backends.backend_mixedmatplotlib.backends.backend_templatematplotlib.backends.backend_aggmatplotlib.backends.backend_cairomatplotlib.backends.backend_gtk3agg, matplotlib.backends.backend_gtk3cairomatplotlib.backends.backend_gtk4agg, matplotlib.backends.backend_gtk4cairomatplotlib.backends.backend_nbaggmatplotlib.backends.backend_pdfmatplotlib.backends.backend_pgfmatplotlib.backends.backend_psmatplotlib.backends.registrymatplotlib.backends.backend_qtagg, matplotlib.backends.backend_qtcairomatplotlib.backends.backend_svgmatplotlib.backends.backend_tkagg, matplotlib.backends.backend_tkcairomatplotlib.backends.backend_webagg_corematplotlib.backends.backend_webaggmatplotlib.backends.backend_wxagg, matplotlib.backends.backend_wxcairomatplotlib.beziermatplotlib.categorymatplotlib.cbookmatplotlib.cmmatplotlib.collectionsmatplotlib.colorbarmatplotlib.colorizermatplotlib.colorsmatplotlib.containermatplotlib.contourmatplotlib.datesmatplotlib.dvireadmatplotlib.figurematplotlib.font_managermatplotlib.ft2fontmatplotlib.gridspec
matplotlib.hatchmatplotlib.imagematplotlib.insetmatplotlib.layout_enginematplotlib.legendmatplotlib.legend_handlermatplotlib.lines
matplotlib.markers
matplotlib.mathtextmatplotlib.mlabmatplotlib.offsetboxmatplotlib.patchesmatplotlib.pathmatplotlib.patheffectsmatplotlib.pyplotmatplotlib.projections
matplotlib.quiver
matplotlib.rcsetupmatplotlib.sankeymatplotlib.scalematplotlib.sphinxext.mathmplmatplotlib.sphinxext.plot_directivematplotlib.sphinxext.figmpl_directivematplotlib.sphinxext.rolesmatplotlib.spinesmatplotlib.stylematplotlib.tablematplotlib.testingmatplotlib.textmatplotlib.texmanagermatplotlib.tickermatplotlib.transformsmatplotlib.trimatplotlib.typingmatplotlib.unitsmatplotlib.widgetsmatplotlib._afmmatplotlib._apimatplotlib._docstringmatplotlib._enumsmatplotlib._type1fontmatplotlib._tight_bboxmatplotlib._tight_layoutmpl_toolkits.mplot3dmpl_toolkits.axes_grid1mpl_toolkits.axisartistpylabmatplotlib.animationAbstract base class for Animations.
Note
You must store the created Animation in a variable that lives as long as the animation should run. Otherwise, the Animation object will be garbage-collected and the animation stops.
FigureThe figure object used to get needed events, such as draw or resize.
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.
Whether blitting is used to optimize drawing. If the backend does not support blitting, then this parameter has no effect.
See also
Methods
|
|
Return a new sequence of frame information. |
|
Return a new sequence of saved/cached frame information. |
|
|
Pause the animation. |
|
Resume the animation. |
|
Save the animation as a movie file by drawing every frame. |
|
Convert the animation to an HTML5 |
|
Generate HTML representation of the animation. |
Save the animation as a movie file by drawing every frame.
The output filename, e.g., mymovie.mp4.
AbstractMovieWriter subclass or str, default: rcParams["animation.writer"] (default: 'ffmpeg')The writer used to grab the frames and create the movie file.
This can be an instance of an AbstractMovieWriter subclass or a
string. The builtin writers are
str |
class |
|---|---|
'ffmpeg' |
|
'ffmpeg_file' |
|
'imagemagick' |
|
'imagemagick_file' |
|
'pillow' |
|
'html' |
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
rcParams["savefig.dpi"] (default: 'figure')Controls the dots per inch for the movie frames. Together with the figure's size in inches, this controls the size of the movie.
rcParams["animation.codec"] (default: 'h264').The video codec to use. Not all codecs are supported by a given
MovieWriter.
rcParams["animation.bitrate"] (default: -1)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 command-line arguments passed to the underlying movie encoder. These
arguments are passed last to the encoder, just before the output filename.
The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for
the builtin writers.
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.
Additional Animation objects that should be included
in the saved movie file. These need to be from the same
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.
Keyword arguments passed to each savefig call used to
save the individual frames.
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 cannot 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}/{n}')
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 RuntimeError will be raised.
Convert the animation to an HTML5 <video> tag.
This saves the animation as an h264 video, encoded in base64
directly into the HTML5 video tag. This respects rcParams["animation.writer"] (default: 'ffmpeg')
and rcParams["animation.bitrate"] (default: -1). This also makes use of the
interval to control the speed, and uses the repeat
parameter to decide whether to loop.
Limit, in MB, of the returned animation. No animation is created
if the limit is exceeded.
Defaults to rcParams["animation.embed_limit"] (default: 20.0) = 20.0.
An HTML5 video tag with the animation embedded as base64 encoded h264 video. If the embed_limit is exceeded, this returns the string "Video too large to embed."
Generate HTML representation of the animation.
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
What to do when the animation ends. Must be one of {'loop',
'once', 'reflect'}. Defaults to 'loop' if the repeat
parameter is True, otherwise 'once'.
An HTML representation of the animation embedded as a js object as
produced with the HTMLWriter.
Copyright 20022012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 20122026 The Matplotlib development team.
Created using Sphinx 9.1.0.
Built from v3.11.2-1-g879ad8ebba.
Built with the PyData Sphinx Theme 0.16.1.
| Web Proxy Viewer | New URL | Original Page |