doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
get_familyname()[source]
Return the font family name, e.g., 'Times'. | matplotlib.afm_api#matplotlib.afm.AFM.get_familyname |
get_fontname()[source]
Return the font name, e.g., 'Times-Roman'. | matplotlib.afm_api#matplotlib.afm.AFM.get_fontname |
get_fullname()[source]
Return the font full name, e.g., 'Times-Roman'. | matplotlib.afm_api#matplotlib.afm.AFM.get_fullname |
get_height_char(c, isord=False)[source]
Get the bounding box (ink) height of character c (space is 0). | matplotlib.afm_api#matplotlib.afm.AFM.get_height_char |
get_horizontal_stem_width()[source]
Return the standard horizontal stem width as float, or None if not specified in AFM file. | matplotlib.afm_api#matplotlib.afm.AFM.get_horizontal_stem_width |
get_kern_dist(c1, c2)[source]
Return the kerning pair distance (possibly 0) for chars c1 and c2. | matplotlib.afm_api#matplotlib.afm.AFM.get_kern_dist |
get_kern_dist_from_name(name1, name2)[source]
Return the kerning pair distance (possibly 0) for chars name1 and name2. | matplotlib.afm_api#matplotlib.afm.AFM.get_kern_dist_from_name |
get_name_char(c, isord=False)[source]
Get the name of the character, i.e., ';' is 'semicolon'. | matplotlib.afm_api#matplotlib.afm.AFM.get_name_char |
get_str_bbox(s)[source]
Return the string bounding box. | matplotlib.afm_api#matplotlib.afm.AFM.get_str_bbox |
get_str_bbox_and_descent(s)[source]
Return the string bounding box and the maximal descent. | matplotlib.afm_api#matplotlib.afm.AFM.get_str_bbox_and_descent |
get_underline_thickness()[source]
Return the underline thickness as float. | matplotlib.afm_api#matplotlib.afm.AFM.get_underline_thickness |
get_vertical_stem_width()[source]
Return the standard vertical stem width as float, or None if not specified in AFM file. | matplotlib.afm_api#matplotlib.afm.AFM.get_vertical_stem_width |
get_weight()[source]
Return the font weight, e.g., 'Bold' or 'Roman'. | matplotlib.afm_api#matplotlib.afm.AFM.get_weight |
get_width_char(c, isord=False)[source]
Get the width of the character from the character metric WX field. | matplotlib.afm_api#matplotlib.afm.AFM.get_width_char |
get_width_from_char_name(name)[source]
Get the width of the character from a type1 character name. | matplotlib.afm_api#matplotlib.afm.AFM.get_width_from_char_name |
get_xheight()[source]
Return the xheight as float. | matplotlib.afm_api#matplotlib.afm.AFM.get_xheight |
string_width_height(s)[source]
Return the string width (including kerning) and string height as a (w, h) tuple. | matplotlib.afm_api#matplotlib.afm.AFM.string_width_height |
classmatplotlib.afm.CharMetrics(width, name, bbox)[source]
Bases: tuple Represents the character metrics of a single character. Notes The fields do currently only describe a subset of character metrics information defined in the AFM standard. Create new instance of CharMetrics(width, name, bbox) bbox
The bbox of the character (B) as a tuple (llx, lly, urx, ury).
name
The character name (N).
width
The character width (WX). | matplotlib.afm_api#matplotlib.afm.CharMetrics |
bbox
The bbox of the character (B) as a tuple (llx, lly, urx, ury). | matplotlib.afm_api#matplotlib.afm.CharMetrics.bbox |
name
The character name (N). | matplotlib.afm_api#matplotlib.afm.CharMetrics.name |
width
The character width (WX). | matplotlib.afm_api#matplotlib.afm.CharMetrics.width |
classmatplotlib.afm.CompositePart(name, dx, dy)[source]
Bases: tuple Represents the information on a composite element of a composite char. Create new instance of CompositePart(name, dx, dy) dx
x-displacement of the part from the origin.
dy
y-displacement of the part from the origin.
name
Name of the part, e.g. 'acute'. | matplotlib.afm_api#matplotlib.afm.CompositePart |
dx
x-displacement of the part from the origin. | matplotlib.afm_api#matplotlib.afm.CompositePart.dx |
dy
y-displacement of the part from the origin. | matplotlib.afm_api#matplotlib.afm.CompositePart.dy |
name
Name of the part, e.g. 'acute'. | matplotlib.afm_api#matplotlib.afm.CompositePart.name |
matplotlib.animation Table of Contents Inheritance Diagrams Animation Writer Classes Helper Classes Inheritance Diagrams Animation The easiest way to make a live animation in Matplotlib is to use one of the Animation classes.
Animation A base class for Animations.
FuncAnimation Makes an animation by repeatedly calling a function func.
ArtistAnimation Animation using a fixed set of Artist objects. In both cases it is critical to keep a reference to the instance object. The animation is advanced by a timer (typically from the host GUI framework) which the Animation object holds the only reference to. If you do not hold a reference to the Animation object, it (and hence the timers) will be garbage collected which will stop the animation. To save an animation use Animation.save, Animation.to_html5_video, or Animation.to_jshtml. See Helper Classes below for details about what movie formats are supported. FuncAnimation The inner workings of FuncAnimation is more-or-less: for d in frames:
artists = func(d, *fargs)
fig.canvas.draw_idle()
fig.canvas.start_event_loop(interval)
with details to handle 'blitting' (to dramatically improve the live performance), to be non-blocking, not repeatedly start/stop the GUI event loop, handle repeats, multiple animated axes, and easily save the animation to a movie file. 'Blitting' is a standard technique in computer graphics. The general gist is to take an existing bit map (in our case a mostly rasterized figure) and then 'blit' one more artist on top. Thus, by managing a saved 'clean' bitmap, we can only re-draw the few artists that are changing at each frame and possibly save significant amounts of time. When we use blitting (by passing blit=True), the core loop of FuncAnimation gets a bit more complicated: ax = fig.gca()
def update_blit(artists):
fig.canvas.restore_region(bg_cache)
for a in artists:
a.axes.draw_artist(a)
ax.figure.canvas.blit(ax.bbox)
artists = init_func()
for a in artists:
a.set_animated(True)
fig.canvas.draw()
bg_cache = fig.canvas.copy_from_bbox(ax.bbox)
for f in frames:
artists = func(f, *fargs)
update_blit(artists)
fig.canvas.start_event_loop(interval)
This is of course leaving out many details (such as updating the background when the figure is resized or fully re-drawn). However, this hopefully minimalist example gives a sense of how init_func and func are used inside of FuncAnimation and the theory of how 'blitting' works. The expected signature on func and init_func is very simple to keep FuncAnimation out of your book keeping and plotting logic, but this means that the callable objects you pass in must know what artists they should be working on. There are several approaches to handling this, of varying complexity and encapsulation. The simplest approach, which works quite well in the case of a script, is to define the artist at a global scope and let Python sort things out. For example import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro')
def init():
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1, 1)
return ln,
def update(frame):
xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)
return ln,
ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
init_func=init, blit=True)
plt.show()
The second method is to use functools.partial to 'bind' artists to function. A third method is to use closures to build up the required artists and functions. A fourth method is to create a class. Examples Decay The Bayes update The double pendulum problem Animated histogram Rain simulation Animated 3D random walk Animated line plot Oscilloscope MATPLOTLIB UNCHAINED ArtistAnimation Examples Animated image using a precomputed list of images Writer Classes The provided writers fall into a few broad categories. The Pillow writer relies on the Pillow library to write the animation, keeping all data in memory.
PillowWriter The HTML writer generates JavaScript-based animations.
HTMLWriter Writer for JavaScript-based HTML movies. The pipe-based writers stream the captured frames over a pipe to an external process. The pipe-based variants tend to be more performant, but may not work on all systems.
FFMpegWriter Pipe-based ffmpeg writer.
ImageMagickWriter Pipe-based animated gif. The file-based writers save temporary files for each frame which are stitched into a single file at the end. Although slower, these writers can be easier to debug.
FFMpegFileWriter File-based ffmpeg writer.
ImageMagickFileWriter File-based animated gif writer. Fundamentally, a MovieWriter provides a way to grab sequential frames from the same underlying Figure object. The base class MovieWriter implements 3 methods and a context manager. The only difference between the pipe-based and file-based writers is in the arguments to their respective setup methods. The setup() method is used to prepare the writer (possibly opening a pipe), successive calls to grab_frame() capture a single frame at a time and finish() finalizes the movie and writes the output file to disk. For example moviewriter = MovieWriter(...)
moviewriter.setup(fig, 'my_movie.ext', dpi=100)
for j in range(n):
update_figure(j)
moviewriter.grab_frame()
moviewriter.finish()
If using the writer classes directly (not through Animation.save), it is strongly encouraged to use the saving context manager with moviewriter.saving(fig, 'myfile.mp4', dpi=100):
for j in range(n):
update_figure(j)
moviewriter.grab_frame()
to ensures that setup and cleanup are performed as necessary. Examples Frame grabbing Helper Classes Animation Base Classes
Animation A base class for Animations.
TimedAnimation Animation subclass for time-based animation. Writer Registry A module-level registry is provided to map between the name of the writer and the class to allow a string to be passed to Animation.save instead of a writer instance.
MovieWriterRegistry Registry of available writer classes by human readable name. Writer Base Classes To reduce code duplication base classes
AbstractMovieWriter Abstract base class for writing movies.
MovieWriter Base class for writing movies.
FileMovieWriter MovieWriter for writing to individual files and stitching at the end. and mixins
FFMpegBase Mixin class for FFMpeg output.
ImageMagickBase Mixin class for ImageMagick output. are provided. See the source code for how to easily implement new MovieWriter classes. | matplotlib.animation_api |
matplotlib.animation.AbstractMovieWriter classmatplotlib.animation.AbstractMovieWriter(fps=5, metadata=None, codec=None, bitrate=None)[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__(fps=5, metadata=None, codec=None, bitrate=None)[source]
Methods
__init__([fps, metadata, codec, bitrate])
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi]) Setup for writing the movie file. Attributes
frame_size A tuple (width, height) in pixels of a movie frame. abstractfinish()[source]
Finish any processing for writing the movie.
propertyframe_size
A tuple (width, height) in pixels of a movie frame.
abstractgrab_frame(**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 call that saves the figure.
saving(fig, outfile, dpi, *args, **kwargs)
Context manager to facilitate writing the movie file. *args, **kw are any parameters that should be passed to setup.
abstractsetup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter |
__init__(fps=5, metadata=None, codec=None, bitrate=None)[source] | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter#matplotlib.animation.AbstractMovieWriter.__init__ |
abstractfinish()[source]
Finish any processing for writing the movie. | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter#matplotlib.animation.AbstractMovieWriter.finish |
abstractgrab_frame(**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 call that saves the figure. | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter#matplotlib.animation.AbstractMovieWriter.grab_frame |
saving(fig, outfile, dpi, *args, **kwargs)
Context manager to facilitate writing the movie file. *args, **kw are any parameters that should be passed to setup. | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter#matplotlib.animation.AbstractMovieWriter.saving |
abstractsetup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. | matplotlib._as_gen.matplotlib.animation.abstractmoviewriter#matplotlib.animation.AbstractMovieWriter.setup |
matplotlib.animation.Animation classmatplotlib.animation.Animation(fig, event_source=None, blit=False)[source]
A base class for Animations. This class is not usable as is, and should be subclassed to provide needed behavior. 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. Parameters
figFigure
The figure object used to get needed events, such as draw or resize.
event_sourceobject, optional
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.
blitbool, default: False
Whether blitting is used to optimize drawing. See also
FuncAnimation, ArtistAnimation
__init__(fig, event_source=None, blit=False)[source]
Methods
__init__(fig[, event_source, blit])
new_frame_seq() Return a new sequence of frame information.
new_saved_frame_seq() Return a new sequence of saved/cached frame information.
pause() Pause the animation.
resume() Resume the animation.
save(filename[, writer, fps, dpi, codec, ...]) Save the animation as a movie file by drawing every frame.
to_html5_video([embed_limit]) Convert the animation to an HTML5 <video> tag.
to_jshtml([fps, embed_frames, default_mode]) Generate HTML representation of the animation. new_frame_seq()[source]
Return a new sequence of frame information.
new_saved_frame_seq()[source]
Return a new sequence of saved/cached frame information.
pause()[source]
Pause the animation.
resume()[source]
Resume the animation.
save(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)[source]
Save the animation as a movie file by drawing every frame. Parameters
filenamestr
The output filename, e.g., mymovie.mp4.
writerMovieWriter or str, default: rcParams["animation.writer"] (default: 'ffmpeg')
A MovieWriter instance to use or a key that identifies a class to use, such as 'ffmpeg'.
fpsint, optional
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
dpifloat, default: 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.
codecstr, default: rcParams["animation.codec"] (default: 'h264').
The video codec to use. Not all codecs are supported by a given MovieWriter.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[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_animlist, 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_kwargsdict, default: {}
Keyword arguments passed to each savefig call used to save the individual frames.
progress_callbackfunction, 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}')
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.
to_html5_video(embed_limit=None)[source]
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. Parameters
embed_limitfloat, optional
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. Returns
str
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."
to_jshtml(fps=None, embed_frames=True, default_mode=None)[source]
Generate HTML representation of the animation. Parameters
fpsint, optional
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
embed_framesbool, optional
default_modestr, optional
What to do when the animation ends. Must be one of {'loop',
'once', 'reflect'}. Defaults to 'loop' if self.repeat is True, otherwise 'once'. | matplotlib._as_gen.matplotlib.animation.animation |
__init__(fig, event_source=None, blit=False)[source] | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.__init__ |
new_frame_seq()[source]
Return a new sequence of frame information. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.new_frame_seq |
new_saved_frame_seq()[source]
Return a new sequence of saved/cached frame information. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.new_saved_frame_seq |
pause()[source]
Pause the animation. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.pause |
resume()[source]
Resume the animation. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.resume |
save(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)[source]
Save the animation as a movie file by drawing every frame. Parameters
filenamestr
The output filename, e.g., mymovie.mp4.
writerMovieWriter or str, default: rcParams["animation.writer"] (default: 'ffmpeg')
A MovieWriter instance to use or a key that identifies a class to use, such as 'ffmpeg'.
fpsint, optional
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
dpifloat, default: 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.
codecstr, default: rcParams["animation.codec"] (default: 'h264').
The video codec to use. Not all codecs are supported by a given MovieWriter.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[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_animlist, 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_kwargsdict, default: {}
Keyword arguments passed to each savefig call used to save the individual frames.
progress_callbackfunction, 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}')
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. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.save |
to_html5_video(embed_limit=None)[source]
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. Parameters
embed_limitfloat, optional
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. Returns
str
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." | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.to_html5_video |
to_jshtml(fps=None, embed_frames=True, default_mode=None)[source]
Generate HTML representation of the animation. Parameters
fpsint, optional
Movie frame rate (per second). If not set, the frame rate from the animation's frame interval.
embed_framesbool, optional
default_modestr, optional
What to do when the animation ends. Must be one of {'loop',
'once', 'reflect'}. Defaults to 'loop' if self.repeat is True, otherwise 'once'. | matplotlib._as_gen.matplotlib.animation.animation#matplotlib.animation.Animation.to_jshtml |
matplotlib.animation.ArtistAnimation classmatplotlib.animation.ArtistAnimation(fig, artists, *args, **kwargs)[source]
Animation using a fixed set of Artist objects. Before creating an instance, all plotting should have taken place and the relevant artists saved. 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. Parameters
figFigure
The figure object used to get needed events, such as draw or resize.
artistslist
Each list entry is a collection of Artist objects that are made visible on the corresponding frame. Other artists are made invisible.
intervalint, default: 200
Delay between frames in milliseconds.
repeat_delayint, default: 0
The delay in milliseconds between consecutive animation runs, if repeat is True.
repeatbool, default: True
Whether the animation repeats when the sequence of frames is completed.
blitbool, default: False
Whether blitting is used to optimize drawing. __init__(fig, artists, *args, **kwargs)[source]
Methods
__init__(fig, artists, *args, **kwargs)
new_frame_seq() Return a new sequence of frame information.
new_saved_frame_seq() Return a new sequence of saved/cached frame information.
pause() Pause the animation.
resume() Resume the animation.
save(filename[, writer, fps, dpi, codec, ...]) Save the animation as a movie file by drawing every frame.
to_html5_video([embed_limit]) Convert the animation to an HTML5 <video> tag.
to_jshtml([fps, embed_frames, default_mode]) Generate HTML representation of the animation. | matplotlib._as_gen.matplotlib.animation.artistanimation |
__init__(fig, artists, *args, **kwargs)[source] | matplotlib._as_gen.matplotlib.animation.artistanimation#matplotlib.animation.ArtistAnimation.__init__ |
matplotlib.animation.FFMpegBase classmatplotlib.animation.FFMpegBase[source]
Mixin class for FFMpeg output. To be useful this must be multiply-inherited from with a MovieWriterBase sub-class. __init__(*args, **kwargs)
Methods
__init__(*args, **kwargs) Attributes
output_args propertyoutput_args | matplotlib._as_gen.matplotlib.animation.ffmpegbase |
__init__(*args, **kwargs) | matplotlib._as_gen.matplotlib.animation.ffmpegbase#matplotlib.animation.FFMpegBase.__init__ |
matplotlib.animation.FFMpegFileWriter classmatplotlib.animation.FFMpegFileWriter(*args, **kwargs)[source]
File-based ffmpeg writer. Frames are written to temporary files on disk and then stitched together at the end. __init__(*args, **kwargs)[source]
Methods
__init__(*args, **kwargs)
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi, frame_prefix]) Setup for writing the movie file. Attributes
frame_format Format (png, jpeg, etc.) to use for saving the frames, which can be decided by the individual subclasses.
frame_size A tuple (width, height) in pixels of a movie frame.
output_args
supported_formats supported_formats=['png', 'jpeg', 'tiff', 'raw', 'rgba'] | matplotlib._as_gen.matplotlib.animation.ffmpegfilewriter |
__init__(*args, **kwargs)[source] | matplotlib._as_gen.matplotlib.animation.ffmpegfilewriter#matplotlib.animation.FFMpegFileWriter.__init__ |
supported_formats=['png', 'jpeg', 'tiff', 'raw', 'rgba'] | matplotlib._as_gen.matplotlib.animation.ffmpegfilewriter#matplotlib.animation.FFMpegFileWriter.supported_formats |
matplotlib.animation.FFMpegWriter classmatplotlib.animation.FFMpegWriter(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Pipe-based ffmpeg writer. Frames are streamed directly to ffmpeg via a pipe and written in a single pass. Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. __init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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.
Methods
__init__([fps, codec, bitrate, extra_args, ...])
Parameters
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi]) Setup for writing the movie file. Attributes
frame_size A tuple (width, height) in pixels of a movie frame.
output_args
supported_formats | matplotlib._as_gen.matplotlib.animation.ffmpegwriter |
__init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. | matplotlib._as_gen.matplotlib.animation.ffmpegwriter#matplotlib.animation.FFMpegWriter.__init__ |
matplotlib.animation.FileMovieWriter classmatplotlib.animation.FileMovieWriter(*args, **kwargs)[source]
MovieWriter for writing to individual files and stitching at the end. This must be sub-classed to be useful. Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. __init__(*args, **kwargs)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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.
Methods
__init__(*args, **kwargs)
Parameters
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi, frame_prefix]) Setup for writing the movie file. Attributes
frame_format Format (png, jpeg, etc.) to use for saving the frames, which can be decided by the individual subclasses.
frame_size A tuple (width, height) in pixels of a movie frame.
supported_formats finish()[source]
Finish any processing for writing the movie.
propertyframe_format
Format (png, jpeg, etc.) to use for saving the frames, which can be decided by the individual subclasses.
grab_frame(**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 call that saves the figure.
setup(fig, outfile, dpi=None, frame_prefix=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure to grab the rendered frames from.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The dpi of the output file. This, with the figure size, controls the size in pixels of the resulting movie file.
frame_prefixstr, optional
The filename prefix to use for temporary files. If None (the default), files are written to a temporary directory which is deleted by cleanup; if not None, no temporary files are deleted. | matplotlib._as_gen.matplotlib.animation.filemoviewriter |
__init__(*args, **kwargs)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. | matplotlib._as_gen.matplotlib.animation.filemoviewriter#matplotlib.animation.FileMovieWriter.__init__ |
finish()[source]
Finish any processing for writing the movie. | matplotlib._as_gen.matplotlib.animation.filemoviewriter#matplotlib.animation.FileMovieWriter.finish |
grab_frame(**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 call that saves the figure. | matplotlib._as_gen.matplotlib.animation.filemoviewriter#matplotlib.animation.FileMovieWriter.grab_frame |
setup(fig, outfile, dpi=None, frame_prefix=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure to grab the rendered frames from.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The dpi of the output file. This, with the figure size, controls the size in pixels of the resulting movie file.
frame_prefixstr, optional
The filename prefix to use for temporary files. If None (the default), files are written to a temporary directory which is deleted by cleanup; if not None, no temporary files are deleted. | matplotlib._as_gen.matplotlib.animation.filemoviewriter#matplotlib.animation.FileMovieWriter.setup |
matplotlib.animation.FuncAnimation classmatplotlib.animation.FuncAnimation(fig, func, frames=None, init_func=None, fargs=None, save_count=None, *, cache_frame_data=True, **kwargs)[source]
Makes an animation by repeatedly calling a function func. 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. Parameters
figFigure
The figure object used to get needed events, such as draw or resize.
funccallable
The function to call at each frame. The first argument will be the next value in frames. Any additional positional arguments can be supplied via the fargs parameter. The required signature is: def func(frame, *fargs) -> iterable_of_artists
If blit == True, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if blit == False and may be omitted in that case.
framesiterable, int, generator function, or None, optional
Source of data to pass func and each frame of the animation If an iterable, then simply use the values provided. If the iterable has a length, it will override the save_count kwarg. If an integer, then equivalent to passing range(frames)
If a generator function, then must have the signature: def gen_function() -> obj
If None, then equivalent to passing itertools.count. In all of these cases, the values in frames is simply passed through to the user-supplied func and thus can be of any type.
init_funccallable, optional
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. This function will be called once before the first frame. The required signature is: def init_func() -> iterable_of_artists
If blit == True, init_func must return an iterable of artists to be re-drawn. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused if blit == False and may be omitted in that case.
fargstuple or None, optional
Additional arguments to pass to each call to func.
save_countint, default: 100
Fallback for the number of values from frames to cache. This is only used if the number of frames cannot be inferred from frames, i.e. when it's an iterator without length or a generator.
intervalint, default: 200
Delay between frames in milliseconds.
repeat_delayint, default: 0
The delay in milliseconds between consecutive animation runs, if repeat is True.
repeatbool, default: True
Whether the animation repeats when the sequence of frames is completed.
blitbool, default: False
Whether blitting is used to optimize drawing. Note: when using blitting, any animated artists will be drawn according to their zorder; however, they will be drawn on top of any previous artists, regardless of their zorder.
cache_frame_databool, default: True
Whether frame data is cached. Disabling cache might be helpful when frames contain large objects. __init__(fig, func, frames=None, init_func=None, fargs=None, save_count=None, *, cache_frame_data=True, **kwargs)[source]
Methods
__init__(fig, func[, frames, init_func, ...])
new_frame_seq() Return a new sequence of frame information.
new_saved_frame_seq() Return a new sequence of saved/cached frame information.
pause() Pause the animation.
resume() Resume the animation.
save(filename[, writer, fps, dpi, codec, ...]) Save the animation as a movie file by drawing every frame.
to_html5_video([embed_limit]) Convert the animation to an HTML5 <video> tag.
to_jshtml([fps, embed_frames, default_mode]) Generate HTML representation of the animation. new_frame_seq()[source]
Return a new sequence of frame information.
new_saved_frame_seq()[source]
Return a new sequence of saved/cached frame information. | matplotlib._as_gen.matplotlib.animation.funcanimation |
__init__(fig, func, frames=None, init_func=None, fargs=None, save_count=None, *, cache_frame_data=True, **kwargs)[source] | matplotlib._as_gen.matplotlib.animation.funcanimation#matplotlib.animation.FuncAnimation.__init__ |
new_frame_seq()[source]
Return a new sequence of frame information. | matplotlib._as_gen.matplotlib.animation.funcanimation#matplotlib.animation.FuncAnimation.new_frame_seq |
new_saved_frame_seq()[source]
Return a new sequence of saved/cached frame information. | matplotlib._as_gen.matplotlib.animation.funcanimation#matplotlib.animation.FuncAnimation.new_saved_frame_seq |
matplotlib.animation.HTMLWriter classmatplotlib.animation.HTMLWriter(fps=30, codec=None, bitrate=None, extra_args=None, metadata=None, embed_frames=False, default_mode='loop', embed_limit=None)[source]
Writer for JavaScript-based HTML movies. Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. __init__(fps=30, codec=None, bitrate=None, extra_args=None, metadata=None, embed_frames=False, default_mode='loop', embed_limit=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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.
Methods
__init__([fps, codec, bitrate, extra_args, ...])
Parameters
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile, dpi[, frame_dir]) Setup for writing the movie file. Attributes
frame_format Format (png, jpeg, etc.) to use for saving the frames, which can be decided by the individual subclasses.
frame_size A tuple (width, height) in pixels of a movie frame.
supported_formats finish()[source]
Finish any processing for writing the movie.
grab_frame(**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 call that saves the figure.
classmethodisAvailable()[source]
Return whether a MovieWriter subclass is actually available.
setup(fig, outfile, dpi, frame_dir=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure to grab the rendered frames from.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The dpi of the output file. This, with the figure size, controls the size in pixels of the resulting movie file.
frame_prefixstr, optional
The filename prefix to use for temporary files. If None (the default), files are written to a temporary directory which is deleted by cleanup; if not None, no temporary files are deleted.
supported_formats=['png', 'jpeg', 'tiff', 'svg'] | matplotlib._as_gen.matplotlib.animation.htmlwriter |
__init__(fps=30, codec=None, bitrate=None, extra_args=None, metadata=None, embed_frames=False, default_mode='loop', embed_limit=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.__init__ |
finish()[source]
Finish any processing for writing the movie. | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.finish |
grab_frame(**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 call that saves the figure. | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.grab_frame |
classmethodisAvailable()[source]
Return whether a MovieWriter subclass is actually available. | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.isAvailable |
setup(fig, outfile, dpi, frame_dir=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure to grab the rendered frames from.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The dpi of the output file. This, with the figure size, controls the size in pixels of the resulting movie file.
frame_prefixstr, optional
The filename prefix to use for temporary files. If None (the default), files are written to a temporary directory which is deleted by cleanup; if not None, no temporary files are deleted. | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.setup |
supported_formats=['png', 'jpeg', 'tiff', 'svg'] | matplotlib._as_gen.matplotlib.animation.htmlwriter#matplotlib.animation.HTMLWriter.supported_formats |
matplotlib.animation.ImageMagickBase classmatplotlib.animation.ImageMagickBase[source]
Mixin class for ImageMagick output. To be useful this must be multiply-inherited from with a MovieWriterBase sub-class. __init__(*args, **kwargs)
Methods
__init__(*args, **kwargs)
bin_path()
isAvailable() Attributes
delay
output_args classmethodbin_path()[source]
propertydelay
classmethodisAvailable()[source]
propertyoutput_args | matplotlib._as_gen.matplotlib.animation.imagemagickbase |
__init__(*args, **kwargs) | matplotlib._as_gen.matplotlib.animation.imagemagickbase#matplotlib.animation.ImageMagickBase.__init__ |
classmethodbin_path()[source] | matplotlib._as_gen.matplotlib.animation.imagemagickbase#matplotlib.animation.ImageMagickBase.bin_path |
classmethodisAvailable()[source] | matplotlib._as_gen.matplotlib.animation.imagemagickbase#matplotlib.animation.ImageMagickBase.isAvailable |
matplotlib.animation.ImageMagickFileWriter classmatplotlib.animation.ImageMagickFileWriter(*args, **kwargs)[source]
File-based animated gif writer. Frames are written to temporary files on disk and then stitched together at the end. __init__(*args, **kwargs)[source]
Methods
__init__(*args, **kwargs)
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi, frame_prefix]) Setup for writing the movie file. Attributes
delay
frame_format Format (png, jpeg, etc.) to use for saving the frames, which can be decided by the individual subclasses.
frame_size A tuple (width, height) in pixels of a movie frame.
output_args
supported_formats supported_formats=['png', 'jpeg', 'tiff', 'raw', 'rgba'] | matplotlib._as_gen.matplotlib.animation.imagemagickfilewriter |
__init__(*args, **kwargs)[source] | matplotlib._as_gen.matplotlib.animation.imagemagickfilewriter#matplotlib.animation.ImageMagickFileWriter.__init__ |
supported_formats=['png', 'jpeg', 'tiff', 'raw', 'rgba'] | matplotlib._as_gen.matplotlib.animation.imagemagickfilewriter#matplotlib.animation.ImageMagickFileWriter.supported_formats |
matplotlib.animation.ImageMagickWriter classmatplotlib.animation.ImageMagickWriter(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Pipe-based animated gif. Frames are streamed directly to ImageMagick via a pipe and written in a single pass. Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. __init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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.
Methods
__init__([fps, codec, bitrate, extra_args, ...])
Parameters
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi]) Setup for writing the movie file. Attributes
delay
frame_size A tuple (width, height) in pixels of a movie frame.
output_args
supported_formats | matplotlib._as_gen.matplotlib.animation.imagemagickwriter |
__init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. | matplotlib._as_gen.matplotlib.animation.imagemagickwriter#matplotlib.animation.ImageMagickWriter.__init__ |
matplotlib.animation.MovieWriter classmatplotlib.animation.MovieWriter(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Base class for writing movies. This is a base class for MovieWriter subclasses that write a movie frame data to a pipe. You cannot instantiate this class directly. See examples for how to use its subclasses. Attributes
frame_formatstr
The format used in writing frame data, defaults to 'rgba'.
figFigure
The figure to capture data from. This must be provided by the sub-classes. Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. __init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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.
Methods
__init__([fps, codec, bitrate, extra_args, ...])
Parameters
bin_path() Return the binary path to the commandline tool used by a specific subclass.
cleanup() [Deprecated]
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable() Return whether a MovieWriter subclass is actually available.
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi]) Setup for writing the movie file. Attributes
frame_size A tuple (width, height) in pixels of a movie frame.
supported_formats classmethodbin_path()[source]
Return the binary path to the commandline tool used by a specific subclass. This is a class method so that the tool can be looked for before making a particular MovieWriter subclass available.
cleanup()[source]
[Deprecated] Notes Deprecated since version 3.4:
finish()[source]
Finish any processing for writing the movie.
grab_frame(**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 call that saves the figure.
classmethodisAvailable()[source]
Return whether a MovieWriter subclass is actually available.
setup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file.
supported_formats=['rgba'] | matplotlib._as_gen.matplotlib.animation.moviewriter |
__init__(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)[source]
Parameters
fpsint, default: 5
Movie frame rate (per second).
codecstr or None, default: rcParams["animation.codec"] (default: 'h264')
The codec to use.
bitrateint, default: 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_argslist of str or None, optional
Extra command-line arguments passed to the underlying movie encoder. The default, None, means to use rcParams["animation.[name-of-encoder]_args"] for the builtin writers.
metadatadict[str, str], default: {}
A 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. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.__init__ |
classmethodbin_path()[source]
Return the binary path to the commandline tool used by a specific subclass. This is a class method so that the tool can be looked for before making a particular MovieWriter subclass available. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.bin_path |
cleanup()[source]
[Deprecated] Notes Deprecated since version 3.4: | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.cleanup |
finish()[source]
Finish any processing for writing the movie. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.finish |
grab_frame(**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 call that saves the figure. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.grab_frame |
classmethodisAvailable()[source]
Return whether a MovieWriter subclass is actually available. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.isAvailable |
setup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.setup |
supported_formats=['rgba'] | matplotlib._as_gen.matplotlib.animation.moviewriter#matplotlib.animation.MovieWriter.supported_formats |
matplotlib.animation.MovieWriterRegistry classmatplotlib.animation.MovieWriterRegistry[source]
Registry of available writer classes by human readable name. __init__()[source]
Methods
__init__()
is_available(name) Check if given writer is available by name.
list() Get a list of available MovieWriters.
register(name) Decorator for registering a class under a name. is_available(name)[source]
Check if given writer is available by name. Parameters
namestr
Returns
bool
list()[source]
Get a list of available MovieWriters.
register(name)[source]
Decorator for registering a class under a name. Example use: @registry.register(name)
class Foo:
pass | matplotlib._as_gen.matplotlib.animation.moviewriterregistry |
__init__()[source] | matplotlib._as_gen.matplotlib.animation.moviewriterregistry#matplotlib.animation.MovieWriterRegistry.__init__ |
is_available(name)[source]
Check if given writer is available by name. Parameters
namestr
Returns
bool | matplotlib._as_gen.matplotlib.animation.moviewriterregistry#matplotlib.animation.MovieWriterRegistry.is_available |
list()[source]
Get a list of available MovieWriters. | matplotlib._as_gen.matplotlib.animation.moviewriterregistry#matplotlib.animation.MovieWriterRegistry.list |
register(name)[source]
Decorator for registering a class under a name. Example use: @registry.register(name)
class Foo:
pass | matplotlib._as_gen.matplotlib.animation.moviewriterregistry#matplotlib.animation.MovieWriterRegistry.register |
matplotlib.animation.PillowWriter classmatplotlib.animation.PillowWriter(fps=5, metadata=None, codec=None, bitrate=None)[source]
__init__(fps=5, metadata=None, codec=None, bitrate=None)[source]
Methods
__init__([fps, metadata, codec, bitrate])
finish() Finish any processing for writing the movie.
grab_frame(**savefig_kwargs) Grab the image information from the figure and save as a movie frame.
isAvailable()
saving(fig, outfile, dpi, *args, **kwargs) Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi]) Setup for writing the movie file. Attributes
frame_size A tuple (width, height) in pixels of a movie frame. finish()[source]
Finish any processing for writing the movie.
grab_frame(**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 call that saves the figure.
classmethodisAvailable()[source]
setup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. | matplotlib._as_gen.matplotlib.animation.pillowwriter |
__init__(fps=5, metadata=None, codec=None, bitrate=None)[source] | matplotlib._as_gen.matplotlib.animation.pillowwriter#matplotlib.animation.PillowWriter.__init__ |
finish()[source]
Finish any processing for writing the movie. | matplotlib._as_gen.matplotlib.animation.pillowwriter#matplotlib.animation.PillowWriter.finish |
grab_frame(**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 call that saves the figure. | matplotlib._as_gen.matplotlib.animation.pillowwriter#matplotlib.animation.PillowWriter.grab_frame |
classmethodisAvailable()[source] | matplotlib._as_gen.matplotlib.animation.pillowwriter#matplotlib.animation.PillowWriter.isAvailable |
setup(fig, outfile, dpi=None)[source]
Setup for writing the movie file. Parameters
figFigure
The figure object that contains the information for frames.
outfilestr
The filename of the resulting movie file.
dpifloat, default: fig.dpi
The DPI (or resolution) for the file. This controls the size in pixels of the resulting movie file. | matplotlib._as_gen.matplotlib.animation.pillowwriter#matplotlib.animation.PillowWriter.setup |
matplotlib.animation.TimedAnimation classmatplotlib.animation.TimedAnimation(fig, interval=200, repeat_delay=0, repeat=True, event_source=None, *args, **kwargs)[source]
Animation subclass for time-based animation. A new frame is drawn every interval milliseconds. 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. Parameters
figFigure
The figure object used to get needed events, such as draw or resize.
intervalint, default: 200
Delay between frames in milliseconds.
repeat_delayint, default: 0
The delay in milliseconds between consecutive animation runs, if repeat is True.
repeatbool, default: True
Whether the animation repeats when the sequence of frames is completed.
blitbool, default: False
Whether blitting is used to optimize drawing. __init__(fig, interval=200, repeat_delay=0, repeat=True, event_source=None, *args, **kwargs)[source]
Methods
__init__(fig[, interval, repeat_delay, ...])
new_frame_seq() Return a new sequence of frame information.
new_saved_frame_seq() Return a new sequence of saved/cached frame information.
pause() Pause the animation.
resume() Resume the animation.
save(filename[, writer, fps, dpi, codec, ...]) Save the animation as a movie file by drawing every frame.
to_html5_video([embed_limit]) Convert the animation to an HTML5 <video> tag.
to_jshtml([fps, embed_frames, default_mode]) Generate HTML representation of the animation. | matplotlib._as_gen.matplotlib.animation.timedanimation |
__init__(fig, interval=200, repeat_delay=0, repeat=True, event_source=None, *args, **kwargs)[source] | matplotlib._as_gen.matplotlib.animation.timedanimation#matplotlib.animation.TimedAnimation.__init__ |
matplotlib.artist Inheritance Diagrams
Artist class classmatplotlib.artist.Artist[source]
Abstract base class for objects that render into a FigureCanvas. Typically, all visible elements in a figure are subclasses of Artist.
Interactive
Artist.add_callback Add a callback function that will be called whenever one of the Artist's properties changes.
Artist.remove_callback Remove a callback based on its observer id.
Artist.pchanged Call all of the registered callbacks.
Artist.get_cursor_data Return the cursor data for a given event.
Artist.format_cursor_data Return a string representation of data.
Artist.mouseover If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
Artist.contains Test whether the artist contains the mouse event.
Artist.pick Process a pick event.
Artist.pickable Return whether the artist is pickable.
Artist.set_picker Define the picking behavior of the artist.
Artist.get_picker Return the picking behavior of the artist. Clipping
Artist.set_clip_on Set whether the artist uses clipping.
Artist.get_clip_on Return whether the artist uses clipping.
Artist.set_clip_box Set the artist's clip Bbox.
Artist.get_clip_box Return the clipbox.
Artist.set_clip_path Set the artist's clip path.
Artist.get_clip_path Return the clip path. Bulk Properties
Artist.update Update this artist's properties from the dict props.
Artist.update_from Copy properties from other to self.
Artist.properties Return a dictionary of all the properties of the artist.
Artist.set Set multiple properties at once. Drawing
Artist.draw Draw the Artist (and its children) using the given renderer.
Artist.set_animated Set whether the artist is intended to be used in an animation.
Artist.get_animated Return whether the artist is animated.
Artist.set_alpha Set the alpha value used for blending - not supported on all backends.
Artist.get_alpha Return the alpha value used for blending - not supported on all backends.
Artist.set_snap Set the snapping behavior.
Artist.get_snap Return the snap setting.
Artist.set_visible Set the artist's visibility.
Artist.get_visible Return the visibility.
Artist.zorder
Artist.set_zorder Set the zorder for the artist.
Artist.get_zorder Return the artist's zorder.
Artist.set_agg_filter Set the agg filter.
Artist.set_sketch_params Set the sketch parameters.
Artist.get_sketch_params Return the sketch parameters for the artist.
Artist.set_rasterized Force rasterized (bitmap) drawing for vector graphics output.
Artist.get_rasterized Return whether the artist is to be rasterized.
Artist.set_path_effects Set the path effects.
Artist.get_path_effects
Artist.get_agg_filter Return filter function to be used for agg filter.
Artist.get_window_extent Get the artist's bounding box in display space.
Artist.get_transformed_clip_path_and_affine Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation. Figure and Axes
Artist.remove Remove the artist from the figure if possible.
Artist.axes The Axes instance the artist resides in, or None.
Artist.set_figure Set the Figure instance the artist belongs to.
Artist.get_figure Return the Figure instance the artist belongs to. Children
Artist.get_children Return a list of the child Artists of this Artist.
Artist.findobj Find artist objects. Transform
Artist.set_transform Set the artist transform.
Artist.get_transform Return the Transform instance used by this artist.
Artist.is_transform_set Return whether the Artist has an explicitly set transform. Units
Artist.convert_xunits Convert x using the unit type of the xaxis.
Artist.convert_yunits Convert y using the unit type of the yaxis.
Artist.have_units Return whether units are set on any axis. Metadata
Artist.set_gid Set the (group) id for the artist.
Artist.get_gid Return the group id.
Artist.set_label Set a label that will be displayed in the legend.
Artist.get_label Return the label used for this artist in the legend.
Artist.set_url Set the url for the artist.
Artist.get_url Return the url. Miscellaneous
Artist.sticky_edges x and y sticky edge lists for autoscaling.
Artist.set_in_layout Set if artist is to be included in layout calculations, E.g.
Artist.get_in_layout Return boolean flag, True if artist is included in layout calculations.
Artist.stale Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist. Functions
allow_rasterization Decorator for Artist.draw method.
get Return the value of an Artist's property, or print all of them.
getp Return the value of an Artist's property, or print all of them.
setp Set one or more properties on an Artist, or list allowed values.
kwdoc Inspect an Artist class (using ArtistInspector) and return information about its settable properties and their current values.
ArtistInspector A helper class to inspect an Artist and return information about its settable properties and their current values. | matplotlib.artist_api |
matplotlib.artist.allow_rasterization matplotlib.artist.allow_rasterization(draw)[source]
Decorator for Artist.draw method. Provides routines that run before and after the draw call. The before and after functions are useful for changing artist-dependent renderer attributes or making other setup function calls, such as starting and flushing a mixed-mode renderer. | matplotlib._as_gen.matplotlib.artist.allow_rasterization |
classmatplotlib.artist.Artist[source]
Abstract base class for objects that render into a FigureCanvas. Typically, all visible elements in a figure are subclasses of Artist. | matplotlib.artist_api#matplotlib.artist.Artist |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.