Bases: object
On import, the FontManager singleton instance creates a list of ttf and afm fonts and caches their FontProperties. The FontManager.findfont method does a nearest neighbor search to find the font that most closely matches the specification. If no good enough match is found, the default font is returned.
Cache the properties of the font at path to make it available to the FontManager. The type of font is inferred from the path suffix.
Find a font that most closely matches the given font properties.
The font properties to search for. This can be either a FontProperties object or a string defining a fontconfig patterns.
The extension of the font file:
If given, only search this directory and its subdirectories.
If True, will fallback to the default font family (usually "DejaVu Sans" or "Helvetica") if the first lookup hard-fails.
Whether to rebuild the font cache and search again if the first match appears to point to a nonexisting font (i.e., the font cache contains outdated entries).
The filename of the best matching font.
This performs a nearest neighbor search. Each font is given a similarity score to the target font properties. The first font with the highest score is returned. If no matches below a certain threshold are found, the default font (usually DejaVu Sans) is returned.
The result is cached, so subsequent lookups don't have to perform the O(n) nearest neighbor search.
See the W3C Cascading Style Sheet, Level 1 documentation for a description of the font finding algorithm.
Return the default font size.
Return the default font weight.
Return a match score between the list of font families in families and the font family name family2.
An exact match at the head of the list returns 0.0.
A match further down the list will return between 0 and 1.
No match will return 1.0.
Return a match score between size1 and size2.
If size2 (the size specified in the font file) is 'scalable', this function always returns 0.0, since any font size can be generated.
Otherwise, the result is the absolute distance between size1 and size2, normalized so that the usual range of font sizes (6pt - 72pt) will lie between 0.0 and 1.0.
Return a match score between stretch1 and stretch2.
The result is the absolute value of the difference between the CSS numeric values of stretch1 and stretch2, normalized between 0.0 and 1.0.
Return a match score between style1 and style2.
An exact match returns 0.0.
A match between 'italic' and 'oblique' returns 0.1.
No match returns 1.0.
Return a match score between variant1 and variant2.
An exact match returns 0.0, otherwise 1.0.
Return a match score between weight1 and weight2.
The result is 0.0 if both weight1 and weight 2 are given as strings and have the same value.
Otherwise, the result is the absolute value of the difference between the CSS numeric values of weight1 and weight2, normalized between 0.05 and 1.0.
Set the default font weight. The initial value is 'normal'.


Cache the properties of the font at path to make it available to the FontManager. The type of font is inferred from the path suffix.


Find a font that most closely matches the given font properties.
The font properties to search for. This can be either a FontProperties object or a string defining a fontconfig patterns.
The extension of the font file:
If given, only search this directory and its subdirectories.
If True, will fallback to the default font family (usually "DejaVu Sans" or "Helvetica") if the first lookup hard-fails.
Whether to rebuild the font cache and search again if the first match appears to point to a nonexisting font (i.e., the font cache contains outdated entries).
The filename of the best matching font.
This performs a nearest neighbor search. Each font is given a similarity score to the target font properties. The first font with the highest score is returned. If no matches below a certain threshold are found, the default font (usually DejaVu Sans) is returned.
The result is cached, so subsequent lookups don't have to perform the O(n) nearest neighbor search.
See the W3C Cascading Style Sheet, Level 1 documentation for a description of the font finding algorithm.


Return a match score between the list of font families in families and the font family name family2.
An exact match at the head of the list returns 0.0.
A match further down the list will return between 0 and 1.
No match will return 1.0.


Return a match score between size1 and size2.
If size2 (the size specified in the font file) is 'scalable', this function always returns 0.0, since any font size can be generated.
Otherwise, the result is the absolute distance between size1 and size2, normalized so that the usual range of font sizes (6pt - 72pt) will lie between 0.0 and 1.0.


Return a match score between stretch1 and stretch2.
The result is the absolute value of the difference between the CSS numeric values of stretch1 and stretch2, normalized between 0.0 and 1.0.


Return a match score between style1 and style2.
An exact match returns 0.0.
A match between 'italic' and 'oblique' returns 0.1.
No match returns 1.0.


Return a match score between variant1 and variant2.
An exact match returns 0.0, otherwise 1.0.


Return a match score between weight1 and weight2.
The result is 0.0 if both weight1 and weight 2 are given as strings and have the same value.
Otherwise, the result is the absolute value of the difference between the CSS numeric values of weight1 and weight2, normalized between 0.05 and 1.0.


Set the default font weight. The initial value is 'normal'.


Bases: object
A class for storing and manipulating font properties.
The font properties are the six properties described in the W3C Cascading Style Sheet, Level 1 font specification and math_fontfamily for math fonts:
Alternatively, a font may be specified using the absolute path to a font file, by using the fname kwarg. However, in this case, it is typically simpler to just pass the path (as a pathlib.Path, not a str) to the font kwarg of the Text object.
The preferred usage of font sizes is to use the relative values, e.g., 'large', instead of absolute font sizes, e.g., 12. This approach allows all text sizes to be made larger or smaller based on the font manager's default font size.
This class will also accept a fontconfig pattern, if it is the only argument provided. This support does not depend on fontconfig; we are merely borrowing its pattern syntax for use here.
Note that Matplotlib's internal font manager and fontconfig use a different algorithm to lookup fonts, so the results of the same pattern may be different in Matplotlib than in other applications that use fontconfig.
Return a copy of self.
Return a list of font names that comprise the font family.
Return the filename of the associated font.
Get a fontconfig pattern suitable for looking up the font as specified with fontconfig's fc-match utility.
This support does not depend on fontconfig; we are merely borrowing its pattern syntax for use here.
Return the name of the font family used for math text.
The default font is rcParams["mathtext.fontset"] (default: 'dejavusans').
Return the name of the font that best matches the font properties.
Return the font size.
Return the font style. Values are: 'normal', 'italic' or 'oblique'.
Return the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'.
Return the font style. Values are: 'normal', 'italic' or 'oblique'.
Return the font variant. Values are: 'normal' or 'small-caps'.
Set the font weight. Options are: A numeric value in the range 0-1000 or one of 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'
Change the font family. May be either an alias (generic name is CSS parlance), such as: 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace', a real font name or a list of real font names. Real font names are not supported when rcParams["text.usetex"] (default: False) is True.
Set the filename of the fontfile to use. In this case, all other properties will be ignored.
Set the properties by parsing a fontconfig pattern.
This support does not depend on fontconfig; we are merely borrowing its pattern syntax for use here.
Set the font family for text in math mode.
If not set explicitly, rcParams["mathtext.fontset"] (default: 'dejavusans') will be used.
The name of the font family.
Available font families are defined in the matplotlibrc.template file here
See also
Change the font family. May be either an alias (generic name is CSS parlance), such as: 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace', a real font name or a list of real font names. Real font names are not supported when rcParams["text.usetex"] (default: False) is True.
Set the font size. Either an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' or an absolute font size, e.g., 12.
Set the font style. Values are: 'normal', 'italic' or 'oblique'.
Set the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded' or 'ultra-expanded', or a numeric value in the range 0-1000.
Set the font style. Values are: 'normal', 'italic' or 'oblique'.
Set the font variant. Values are: 'normal' or 'small-caps'.
Set the font weight. May be either a numeric value in the range 0-1000 or one of 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'


Return a list of font names that comprise the font family.


Return the filename of the associated font.


Get a fontconfig pattern suitable for looking up the font as specified with fontconfig's fc-match utility.
This support does not depend on fontconfig; we are merely borrowing its pattern syntax for use here.


Return the name of the font family used for math text.
The default font is rcParams["mathtext.fontset"] (default: 'dejavusans').


Return the name of the font that best matches the font properties.


Return the font style. Values are: 'normal', 'italic' or 'oblique'.


Return the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'.


Return the font variant. Values are: 'normal' or 'small-caps'.


Set the font weight. Options are: A numeric value in the range 0-1000 or one of 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'


Change the font family. May be either an alias (generic name is CSS parlance), such as: 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace', a real font name or a list of real font names. Real font names are not supported when rcParams["text.usetex"] (default: False) is True.


Set the filename of the fontfile to use. In this case, all other properties will be ignored.


Set the properties by parsing a fontconfig pattern.
This support does not depend on fontconfig; we are merely borrowing its pattern syntax for use here.


Set the font family for text in math mode.
If not set explicitly, rcParams["mathtext.fontset"] (default: 'dejavusans') will be used.
The name of the font family.
Available font families are defined in the matplotlibrc.template file here
See also


Set the font size. Either an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' or an absolute font size, e.g., 12.


Set the font style. Values are: 'normal', 'italic' or 'oblique'.


Set the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded' or 'ultra-expanded', or a numeric value in the range 0-1000.


Set the font variant. Values are: 'normal' or 'small-caps'.


Set the font weight. May be either a numeric value in the range 0-1000 or one of 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'


[Deprecated] List font filenames known to fc-list having the given extension.
Deprecated since version 3.5.


Return a list of file extensions extensions that are synonyms for the given file extension fileext.


Return whether the given font is a Postscript Compact Font Format Font embedded in an OpenType wrapper. Used by the PostScript and PDF backends that can not subset these fonts.


Dump FontManager data as JSON to the file named filename.
See also
File paths that are children of the Matplotlib data path (typically, fonts shipped with Matplotlib) are stored relative to that data path (to remain valid across virtualenvs).
This function temporarily locks the output file to prevent multiple processes from overwriting one another's output.


Load a FontManager from the JSON file named filename.
See also


Return a list of all fonts matching any of the extensions, found recursively under the directory.


Extract information from a TrueType font file.
The TrueType font file from which information will be extracted.
The extracted font properties.


Return the user-specified font directory for Win32. This is looked up from the registry key
If the key is not found, %WINDIR%\Fonts will be returned.


[Deprecated] Search for fonts in the specified font directory, or use the system directories if none given. Additionally, it is searched for user fonts installed. A list of TrueType font filenames are returned by default, or AFM fonts if fontext == 'afm'.
Deprecated since version 3.5.


A module for parsing and generating fontconfig patterns.
Bases: object
A simple pyparsing-based parser for fontconfig patterns.
Parse the given fontconfig pattern and return a dictionary of key/value pairs useful for initializing a font_manager.FontProperties object.
Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.
Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.
Given a dictionary of key/value pairs, generates a fontconfig pattern string.
Parse the given fontconfig pattern and return a dictionary of key/value pairs useful for initializing a font_manager.FontProperties object.
Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.
Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.


Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.


Bases: object
A simple pyparsing-based parser for fontconfig patterns.
Parse the given fontconfig pattern and return a dictionary of key/value pairs useful for initializing a font_manager.FontProperties object.


Parse the given fontconfig pattern and return a dictionary of key/value pairs useful for initializing a font_manager.FontProperties object.


Given a dictionary of key/value pairs, generates a fontconfig pattern string.


Return the name of the current backend.
See also


Return the string path of the cache directory.
The procedure used to find the directory is the same as for _get_config_dir, except using $XDG_CACHE_HOME/$HOME/.cache instead.


Return the string path of the configuration directory.
The directory is chosen as follows:


gridspec contains classes that help to layout multiple Axes in a grid-like pattern within a figure.
The GridSpec specifies the overall grid structure. Individual cells within the grid are referenced by SubplotSpecs.
Often, users need not access this module directly, and can use higher-level methods like subplots, subplot_mosaic and subfigures. See the tutorial Arranging multiple Axes in a Figure for a guide.
GridSpec(nrows, ncols[, figure, left, ...])
A grid layout to place subplots within a figure.
SubplotSpec(gridspec, num1[, num2])
The location of a subplot in a GridSpec.
GridSpecBase(nrows, ncols[, height_ratios, ...])
A base class of GridSpec that specifies the geometry of the grid that a subplot will be placed.
GridSpecFromSubplotSpec(nrows, ncols, ...[, ...])
GridSpec whose subplot layout parameters are inherited from the location specified by a given SubplotSpec.


Bases: matplotlib.gridspec.GridSpecBase
A grid layout to place subplots within a figure.
The location of the grid cells is determined in a similar way to SubplotParams using left, right, top, bottom, wspace and hspace.
The number of rows and columns of the grid.
Only used for constrained layout to create a proper layoutgrid.
Extent of the subplots as a fraction of figure width or height. Left cannot be larger than right, and bottom cannot be larger than top. If not given, the values will be inferred from a figure or rcParams at draw time. See also GridSpec.get_subplot_params.
The amount of width reserved for space between subplots, expressed as a fraction of the average axis width. If not given, the values will be inferred from a figure or rcParams when necessary. See also GridSpec.get_subplot_params.
The amount of height reserved for space between subplots, expressed as a fraction of the average axis height. If not given, the values will be inferred from a figure or rcParams when necessary. See also GridSpec.get_subplot_params.
Defines the relative widths of the columns. Each column gets a relative width of width_ratios[i] / sum(width_ratios). If not given, all columns will have the same width.
Defines the relative heights of the rows. Each row gets a relative height of height_ratios[i] / sum(height_ratios). If not given, all rows will have the same height.
Return the SubplotParams for the GridSpec.
In order of precedence the values are taken from
Return a list of the names of the subplot parameters explicitly set in the GridSpec.
This is a subset of the attributes of SubplotParams.
Adjust subplot parameters to give specified padding.
Padding between the figure edge and the edges of subplots, as a fraction of the font-size.
Padding (height/width) between edges of adjacent subplots. Defaults to pad.
(left, bottom, right, top) rectangle in normalized figure coordinates that the whole subplots area (including labels) will fit into.
Update the subplot parameters of the grid.
Parameters that are not explicitly given are not changed. Setting a parameter to None resets it to rcParams["figure.subplot.*"].
Extent of the subplots as a fraction of figure width or height.
Spacing between the subplots as a fraction of the average subplot width / height.
Psd Demo
Scatter plot with histograms
Streamplot
Aligning Labels
Resizing axes with constrained layout
Resizing axes with tight layout
Combining two subplots using subplots and GridSpec
Using Gridspec to make multi-column/row subplot layouts
Nested Gridspecs
Figure subfigures
Creating multiple subplots using plt.subplots
Text Rotation Mode
Custom spines with axisartist
GridSpec demo
Nested GridSpecs
Constrained Layout Guide
Tight Layout guide
Arranging multiple Axes in a Figure
origin and extent in imshow


Return the SubplotParams for the GridSpec.
In order of precedence the values are taken from


Return a list of the names of the subplot parameters explicitly set in the GridSpec.
This is a subset of the attributes of SubplotParams.


Adjust subplot parameters to give specified padding.
Padding between the figure edge and the edges of subplots, as a fraction of the font-size.
Padding (height/width) between edges of adjacent subplots. Defaults to pad.
(left, bottom, right, top) rectangle in normalized figure coordinates that the whole subplots area (including labels) will fit into.


Update the subplot parameters of the grid.
Parameters that are not explicitly given are not changed. Setting a parameter to None resets it to rcParams["figure.subplot.*"].
Extent of the subplots as a fraction of figure width or height.
Spacing between the subplots as a fraction of the average subplot width / height.


Bases: object
A base class of GridSpec that specifies the geometry of the grid that a subplot will be placed.
The number of rows and columns of the grid.
Defines the relative widths of the columns. Each column gets a relative width of width_ratios[i] / sum(width_ratios). If not given, all columns will have the same width.
Defines the relative heights of the rows. Each row gets a relative height of height_ratios[i] / sum(height_ratios). If not given, all rows will have the same height.
Return a tuple containing the number of rows and columns in the grid.
Return the positions of the grid cells in figure coordinates.
The figure the grid should be applied to. The subplot parameters (margins and spacing between subplots) are taken from fig.
If True, the subplot parameters of the figure are not taken into account. The grid spans the range [0, 1] in both directions without margins and there is no space between grid cells. This is used for constrained_layout.
The bottom, top, left, right positions of the grid cells in figure coordinates.
Return the height ratios.
This is None if no height ratios have been set explicitly.
Return the width ratios.
This is None if no width ratios have been set explicitly.
The number of columns in the grid.
Create and return a SubplotSpec instance.
The position of the subplot in the grid as (row_index, column_index).
The number of rows and columns the subplot should span in the grid.
The number of rows in the grid.
Set the relative heights of the rows.
height_ratios must be of length nrows. Each row gets a relative height of height_ratios[i] / sum(height_ratios).
Set the relative widths of the columns.
width_ratios must be of length ncols. Each column gets a relative width of width_ratios[i] / sum(width_ratios).
Add all subplots specified by this GridSpec to its parent figure.
See Figure.subplots for detailed documentation.
Psd Demo
Streamplot
Aligning Labels
Resizing axes with constrained layout
Using Gridspec to make multi-column/row subplot layouts
Nested Gridspecs
GridSpec demo
Constrained Layout Guide
Tight Layout guide
origin and extent in imshow


Return a tuple containing the number of rows and columns in the grid.


Return the positions of the grid cells in figure coordinates.
The figure the grid should be applied to. The subplot parameters (margins and spacing between subplots) are taken from fig.
If True, the subplot parameters of the figure are not taken into account. The grid spans the range [0, 1] in both directions without margins and there is no space between grid cells. This is used for constrained_layout.
The bottom, top, left, right positions of the grid cells in figure coordinates.


Return the height ratios.
This is None if no height ratios have been set explicitly.


Return the width ratios.
This is None if no width ratios have been set explicitly.


Create and return a SubplotSpec instance.
The position of the subplot in the grid as (row_index, column_index).
The number of rows and columns the subplot should span in the grid.


Set the relative heights of the rows.
height_ratios must be of length nrows. Each row gets a relative height of height_ratios[i] / sum(height_ratios).


Set the relative widths of the columns.
width_ratios must be of length ncols. Each column gets a relative width of width_ratios[i] / sum(width_ratios).


Add all subplots specified by this GridSpec to its parent figure.
See Figure.subplots for detailed documentation.


Bases: matplotlib.gridspec.GridSpecBase
GridSpec whose subplot layout parameters are inherited from the location specified by a given SubplotSpec.
Number of rows and number of columns of the grid.
Spec from which the layout parameters are inherited.
See GridSpec for more details. If not specified default values (from the figure or rcParams) are used.
See GridSpecBase for details.
See GridSpecBase for details.
Return a dictionary of subplot layout parameters.
Return the topmost SubplotSpec instance associated with the subplot.
Resizing axes with constrained layout
Nested Gridspecs
Nested GridSpecs
Constrained Layout Guide
Arranging multiple Axes in a Figure


Return a dictionary of subplot layout parameters.


Return the topmost SubplotSpec instance associated with the subplot.


Bases: object
The location of a subplot in a GridSpec.
Note
Likely, you'll never instantiate a SubplotSpec yourself. Instead you will typically obtain one from a GridSpec using item-access.
The GridSpec, which the subplot is referencing.
The subplot will occupy the num1-th cell of the given gridspec. If num2 is provided, the subplot will span between num1-th cell and num2-th cell inclusive.
The index starts from 0.
The columns spanned by this subplot, as a range object.
Return the subplot geometry as tuple (n_rows, n_cols, start, stop).
The indices start and stop define the range of the subplot within the GridSpec. stop is inclusive (i.e. for a single cell start == stop).
Update the subplot position from figure.subplotpars.
Return the topmost SubplotSpec instance associated with the subplot.
The rows spanned by this subplot, as a range object.
Create a GridSpec within this subplot.
The created GridSpecFromSubplotSpec will have this SubplotSpec as a parent.
Number of rows in grid.
Number or columns in grid.
All other parameters are passed to GridSpecFromSubplotSpec.
See also
Adding three subplots in the space occupied by a single subplot:
Nested GridSpecs
Constrained Layout Guide
Arranging multiple Axes in a Figure


Return the subplot geometry as tuple (n_rows, n_cols, start, stop).
The indices start and stop define the range of the subplot within the GridSpec. stop is inclusive (i.e. for a single cell start == stop).


Update the subplot position from figure.subplotpars.


Create a GridSpec within this subplot.
The created GridSpecFromSubplotSpec will have this SubplotSpec as a parent.
Number of rows in grid.
Number or columns in grid.
All other parameters are passed to GridSpecFromSubplotSpec.
See also
Adding three subplots in the space occupied by a single subplot:


The image module supports basic image loading, rescaling and display operations.
Bases: matplotlib.image._ImageBase
An image attached to an Axes.
The axes the image will belong to.
The Colormap instance or registered colormap name used to map scalar data to colors.
Maps luminance to 0-1.
Supported values are 'none', 'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'.
If 'data', interpolation is carried out on the data provided by the user. If 'rgba', the interpolation is carried out after the colormapping has been applied (visual interpolation).
Place the [0, 0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images.
The data axes (left, right, bottom, top) for making image plots registered with data plots. Default is to label the pixel centers with the zero-based row and column indices.
A parameter for the antigrain image resize filter (see the antigrain documentation). If filternorm is set, the filter normalizes integer values and corrects the rounding errors. It doesn't do anything with the source floating point values, it corrects only integers according to the rule of 1.0 which means that any sum of pixel weights must be equal to 1.0. So, the filter function must produce a graph of the proper shape.
The filter radius for filters that have a radius parameter, i.e. when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
When True, use a full resampling method. When False, only resample when the output image is larger than the input image.
The normalizing object which scales data, typically into the interval [0, 1]. If None, norm defaults to a colors.Normalize object which initializes its scaling based on the first data processed.
The colormap used to map normalized data values to RGBA colors.
Return the image value at the event position or None if the event is outside the image.
See also
Return the image extent as tuple (left, right, bottom, top).
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Set the image extent.
The position and size of the image as tuple (left, right, bottom, top) in data coordinates.
This updates ax.dataLim, and, if autoscaling, sets ax.viewLim to tightly fit the image, regardless of dataLim. Autoscaling state is not changed, so following this with ax.autoscale_view() will redo the autoscaling in accord with dataLim.
Bases: matplotlib.image._ImageBase
The Image class whose size is determined by the given bbox.
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
kwargs are an optional list of Artist keyword args
Test whether the mouse event occurred within the image.
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Bases: matplotlib.image._ImageBase
An image attached to a figure.
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
kwargs are an optional list of Artist keyword args
Return the image extent as tuple (left, right, bottom, top).
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Set the image array.
Bases: matplotlib.image.AxesImage
All other keyword arguments are identical to those of AxesImage.
Return the image extent as tuple (left, right, bottom, top).
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
unknown
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
unknown
filterrad
unknown
gid
str
in_layout
bool
interpolation
{'nearest', 'bilinear'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
unknown
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Retained for backwards compatibility - use set_data instead.
Set the colormap for luminance data.
Set the grid for the pixel centers, and the pixel values.
Monotonic arrays of shapes (N,) and (M,), respectively, specifying pixel centers.
(M, N) ndarray or masked array of values to be colormapped, or (M, N, 3) RGB array, or (M, N, 4) RGBA array.
Set whether the resize filter normalizes the weights.
See help for imshow.
Set the resize filter radius only applicable to some interpolation schemes -- see help for imshow
If None, use rcParams["image.interpolation"] (default: 'antialiased').
Set the normalization instance.
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
Bases: matplotlib.image.AxesImage
Make a pcolor-style plot with an irregular rectangular grid.
This uses a variation of the original irregular image code, and it is used by pcolorfast for the corresponding grid type.
The axes the image will belong to.
Monotonic arrays of length N+1 and M+1, respectively, specifying rectangle boundaries. If not given, will default to range(N + 1) and range(M + 1), respectively.
The data to be color-coded. The interpretation depends on the shape:
The Colormap instance or registered colormap name used to map scalar data to colors.
Maps luminance to 0-1.
Return the image value at the event position or None if the event is outside the image.
See also
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Retained for backwards compatibility - use set_data instead.
Set the grid for the rectangle boundaries, and the data values.
Monotonic arrays of length N+1 and M+1, respectively, specifying rectangle boundaries. If not given, will default to range(N + 1) and range(M + 1), respectively.
The data to be color-coded. The interpretation depends on the shape:
Composite a number of RGBA images into one. The images are composited in the order in which they appear in the images list.
Each must have a make_image method. For each image, can_composite should return True, though this is not enforced by this function. Each image must have a purely affine transformation with no shear.
The additional magnification to apply for the renderer in use.
The composited RGBA image.
The (left, bottom) offset where the composited image should be placed in the output figure.
Read an image from a file into an array.
Note
This function exists for historical reasons. It is recommended to use PIL.Image.open instead for loading images.
The image file to read: a filename, a URL or a file-like object opened in read-binary mode.
Passing a URL is deprecated. Please open the URL for reading and pass the result to Pillow, e.g. with np.array(PIL.Image.open(urllib.request.urlopen(url))).
The image file format assumed for reading the data. The image is loaded as a PNG file if format is set to "png", if fname is a path or opened file with a ".png" extension, or if it is an URL. In all other cases, format is ignored and the format is auto-detected by PIL.Image.open.
The image data. The returned array has shape
PNG images are returned as float arrays (0-1). All other formats are returned as int arrays, with a bit depth determined by the file's contents.
Save an array as an image file.
A path or a file-like object to store the image in. If format is not set, then the output format is inferred from the extension of fname, if any, and from rcParams["savefig.format"] (default: 'png') otherwise. If format is set, it determines the output format.
The image data. The shape can be one of MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA).
vmin and vmax set the color scaling for the image by fixing the values that map to the colormap color limits. If either vmin or vmax is None, that limit is determined from the arr min/max value.
A Colormap instance or registered colormap name. The colormap maps scalar data to colors. It is ignored for RGB(A) data.
The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when this is unset is documented under fname.
Indicates whether the (0, 0) index of the array is in the upper left or lower left corner of the axes.
The DPI to store in the metadata of the file. This does not affect the resolution of the output image. Depending on file format, this may be rounded to the nearest integer.
Metadata in the image file. The supported keys depend on the output format, see the documentation of the respective backends for more information.
Keyword arguments passed to PIL.Image.Image.save. If the 'pnginfo' key is present, it completely overrides metadata, including the default 'Software' key.
Load a PIL image and return it as a numpy int array.
The array shape depends on the image type:
Make a thumbnail of image in infile with output filename thumbfile.
See Image Thumbnail.
The image file. Matplotlib relies on Pillow for image reading, and thus supports a wide range of file formats, including PNG, JPG, TIFF and others.
The thumbnail filename.
The scale factor for the thumbnail.
The interpolation scheme used in the resampling. See the interpolation parameter of imshow for possible values.
If True, the default backend (presumably a user interface backend) will be used which will cause a figure to be raised if show is called. If it is False, the figure is created using FigureCanvasBase and the drawing backend is selected as Figure.savefig would normally do.
The figure instance containing the thumbnail.


Bases: matplotlib.image._ImageBase
An image attached to an Axes.
The axes the image will belong to.
The Colormap instance or registered colormap name used to map scalar data to colors.
Maps luminance to 0-1.
Supported values are 'none', 'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'.
If 'data', interpolation is carried out on the data provided by the user. If 'rgba', the interpolation is carried out after the colormapping has been applied (visual interpolation).
Place the [0, 0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images.
The data axes (left, right, bottom, top) for making image plots registered with data plots. Default is to label the pixel centers with the zero-based row and column indices.
A parameter for the antigrain image resize filter (see the antigrain documentation). If filternorm is set, the filter normalizes integer values and corrects the rounding errors. It doesn't do anything with the source floating point values, it corrects only integers according to the rule of 1.0 which means that any sum of pixel weights must be equal to 1.0. So, the filter function must produce a graph of the proper shape.
The filter radius for filters that have a radius parameter, i.e. when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
When True, use a full resampling method. When False, only resample when the output image is larger than the input image.
The normalizing object which scales data, typically into the interval [0, 1]. If None, norm defaults to a colors.Normalize object which initializes its scaling based on the first data processed.
The colormap used to map normalized data values to RGBA colors.
Return the image value at the event position or None if the event is outside the image.
See also
Return the image extent as tuple (left, right, bottom, top).
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Set the image extent.
The position and size of the image as tuple (left, right, bottom, top) in data coordinates.
This updates ax.dataLim, and, if autoscaling, sets ax.viewLim to tightly fit the image, regardless of dataLim. Autoscaling state is not changed, so following this with ax.autoscale_view() will redo the autoscaling in accord with dataLim.


Return the image value at the event position or None if the event is outside the image.
See also


Return the image extent as tuple (left, right, bottom, top).


Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.


Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Set the image extent.
The position and size of the image as tuple (left, right, bottom, top) in data coordinates.
This updates ax.dataLim, and, if autoscaling, sets ax.viewLim to tightly fit the image, regardless of dataLim. Autoscaling state is not changed, so following this with ax.autoscale_view() will redo the autoscaling in accord with dataLim.


Bases: matplotlib.image._ImageBase
The Image class whose size is determined by the given bbox.
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
kwargs are an optional list of Artist keyword args
Test whether the mouse event occurred within the image.
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Test whether the mouse event occurred within the image.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
array-like or PIL.Image.Image
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Composite a number of RGBA images into one. The images are composited in the order in which they appear in the images list.
Each must have a make_image method. For each image, can_composite should return True, though this is not enforced by this function. Each image must have a purely affine transformation with no shear.
The additional magnification to apply for the renderer in use.
The composited RGBA image.
The (left, bottom) offset where the composited image should be placed in the output figure.


Bases: matplotlib.image._ImageBase
An image attached to a figure.
cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1
kwargs are an optional list of Artist keyword args
Return the image extent as tuple (left, right, bottom, top).
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Set the image array.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
array-like
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Read an image from a file into an array.
Note
This function exists for historical reasons. It is recommended to use PIL.Image.open instead for loading images.
The image file to read: a filename, a URL or a file-like object opened in read-binary mode.
Passing a URL is deprecated. Please open the URL for reading and pass the result to Pillow, e.g. with np.array(PIL.Image.open(urllib.request.urlopen(url))).
The image file format assumed for reading the data. The image is loaded as a PNG file if format is set to "png", if fname is a path or opened file with a ".png" extension, or if it is an URL. In all other cases, format is ignored and the format is auto-detected by PIL.Image.open.
The image data. The returned array has shape
PNG images are returned as float arrays (0-1). All other formats are returned as int arrays, with a bit depth determined by the file's contents.


Save an array as an image file.
A path or a file-like object to store the image in. If format is not set, then the output format is inferred from the extension of fname, if any, and from rcParams["savefig.format"] (default: 'png') otherwise. If format is set, it determines the output format.
The image data. The shape can be one of MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA).
vmin and vmax set the color scaling for the image by fixing the values that map to the colormap color limits. If either vmin or vmax is None, that limit is determined from the arr min/max value.
A Colormap instance or registered colormap name. The colormap maps scalar data to colors. It is ignored for RGB(A) data.
The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when this is unset is documented under fname.
Indicates whether the (0, 0) index of the array is in the upper left or lower left corner of the axes.
The DPI to store in the metadata of the file. This does not affect the resolution of the output image. Depending on file format, this may be rounded to the nearest integer.
Metadata in the image file. The supported keys depend on the output format, see the documentation of the respective backends for more information.
Keyword arguments passed to PIL.Image.Image.save. If the 'pnginfo' key is present, it completely overrides metadata, including the default 'Software' key.


Bases: matplotlib.image.AxesImage
All other keyword arguments are identical to those of AxesImage.
Return the image extent as tuple (left, right, bottom, top).
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
unknown
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
unknown
filterrad
unknown
gid
str
in_layout
bool
interpolation
{'nearest', 'bilinear'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
unknown
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Retained for backwards compatibility - use set_data instead.
Set the colormap for luminance data.
Set the grid for the pixel centers, and the pixel values.
Monotonic arrays of shapes (N,) and (M,), respectively, specifying pixel centers.
(M, N) ndarray or masked array of values to be colormapped, or (M, N, 3) RGB array, or (M, N, 4) RGBA array.
Set whether the resize filter normalizes the weights.
See help for imshow.
Set the resize filter radius only applicable to some interpolation schemes -- see help for imshow
If None, use rcParams["image.interpolation"] (default: 'antialiased').
Set the normalization instance.
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
unknown
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
unknown
filterrad
unknown
gid
str
in_layout
bool
interpolation
{'nearest', 'bilinear'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
unknown
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Retained for backwards compatibility - use set_data instead.


Set the grid for the pixel centers, and the pixel values.
Monotonic arrays of shapes (N,) and (M,), respectively, specifying pixel centers.
(M, N) ndarray or masked array of values to be colormapped, or (M, N, 3) RGB array, or (M, N, 4) RGBA array.


Set whether the resize filter normalizes the weights.
See help for imshow.


Set the resize filter radius only applicable to some interpolation schemes -- see help for imshow


If None, use rcParams["image.interpolation"] (default: 'antialiased').


Set the normalization instance.
If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.


Bases: matplotlib.image.AxesImage
Make a pcolor-style plot with an irregular rectangular grid.
This uses a variation of the original irregular image code, and it is used by pcolorfast for the corresponding grid type.
The axes the image will belong to.
Monotonic arrays of length N+1 and M+1, respectively, specifying rectangle boundaries. If not given, will default to range(N + 1) and range(M + 1), respectively.
The data to be color-coded. The interpretation depends on the shape:
The Colormap instance or registered colormap name used to map scalar data to colors.
Maps luminance to 0-1.
Return the image value at the event position or None if the event is outside the image.
See also
Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Retained for backwards compatibility - use set_data instead.
Set the grid for the rectangle boundaries, and the data values.
Monotonic arrays of length N+1 and M+1, respectively, specifying rectangle boundaries. If not given, will default to range(N + 1) and range(M + 1), respectively.
The data to be color-coded. The interpretation depends on the shape:


Return the image value at the event position or None if the event is outside the image.
See also


Normalize, rescale, and colormap this image's data for rendering using renderer, with the given magnification.
If unsampled is True, the image will not be scaled, but an appropriate affine transformation will be returned instead.
The RGBA image, resampled unless unsampled is True.
The upper left corner where the image should be drawn, in pixel space.
The affine transformation from image to pixel space.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
float or 2D array-like or None
animated
bool
array
unknown
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
data
unknown
extent
4-tuple of float
figure
Figure
filternorm
bool
filterrad
positive float
gid
str
in_layout
bool
interpolation
{'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
interpolation_stage
{'data', 'rgba'} or None
label
object
norm
Normalize or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
resample
bool or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Set the grid for the rectangle boundaries, and the data values.
Monotonic arrays of length N+1 and M+1, respectively, specifying rectangle boundaries. If not given, will default to range(N + 1) and range(M + 1), respectively.
The data to be color-coded. The interpretation depends on the shape:


Load a PIL image and return it as a numpy int array.
The array shape depends on the image type:


Make a thumbnail of image in infile with output filename thumbfile.
See Image Thumbnail.
The image file. Matplotlib relies on Pillow for image reading, and thus supports a wide range of file formats, including PNG, JPG, TIFF and others.
The thumbnail filename.
The scale factor for the thumbnail.
The interpolation scheme used in the resampling. See the interpolation parameter of imshow for possible values.
If True, the default backend (presumably a user interface backend) will be used which will cause a figure to be raised if show is called. If it is False, the figure is created using FigureCanvasBase and the drawing backend is selected as Figure.savefig would normally do.
The figure instance containing the thumbnail.


Set whether to redraw after every plotting command (e.g. pyplot.xlabel).


Return whether to redraw after every plotting command.
Note
This function is only intended for use in backends. End users should use pyplot.isinteractive instead.


The legend module defines the Legend class, which is responsible for drawing legends associated with axes and/or figures.
Important
It is unlikely that you would ever create a Legend instance manually. Most users would normally create a legend via the legend function. For more details on legends there is also a legend guide.
The Legend class is a container of legend handles and legend texts.
The legend handler map specifies how to create legend handles from artists (lines, patches, etc.) in the axes or figures. Default legend handlers are defined in the legend_handler module. While not all artist types are covered by the default legend handlers, custom legend handlers can be defined to support arbitrary objects.
See the legend guide for more information.
Bases: matplotlib.offsetbox.DraggableOffsetBox
Wrapper around a Legend to support mouse dragging.
The Legend instance to wrap.
Use blitting for faster image composition. For details see FuncAnimation.
If "loc", update the loc parameter of the legend upon finalizing. If "bbox", update the bbox_to_anchor parameter.
Bases: matplotlib.artist.Artist
Place a legend on the axes at location loc.
The artist that contains the legend.
A list of Artists (lines, patches) to be added to the legend.
A list of labels to show next to the artists. The length of handles and labels should be the same. If they are not, they are truncated to the smaller of both lengths.
The location of the legend.
The strings 'upper left', 'upper right', 'lower left', 'lower right' place the legend at the corresponding corner of the axes/figure.
The strings 'upper center', 'lower center', 'center left', 'center right' place the legend at the center of the corresponding edge of the axes/figure.
The string 'center' places the legend at the center of the axes/figure.
The string 'best' places the legend at the location, among the nine locations defined so far, with the minimum overlap with other drawn artists. This option can be quite slow for plots with large amounts of data; your plotting speed may benefit from providing a specific location.
The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in axes coordinates (in which case bbox_to_anchor will be ignored).
For back-compatibility, 'center right' (but no other location) can also be spelled 'right', and each "string" locations can also be given as a numeric value:
Location String
Location Code
'best'
0
'upper right'
1
'upper left'
2
'lower left'
3
'lower right'
4
'right'
5
'center left'
6
'center right'
7
'lower center'
8
'upper center'
9
'center'
10
Box that is used to position the legend in conjunction with loc. Defaults to axes.bbox (if called as a method to Axes.legend) or figure.bbox (if Figure.legend). This argument allows arbitrary placement of the legend.
Bbox coordinates are interpreted in the coordinate system given by bbox_transform, with the default transform Axes or Figure coordinates, depending on which legend is called.
If a 4-tuple or BboxBase is given, then it specifies the bbox (x, y, width, height) that the legend is placed in. To put the legend in the best location in the bottom right quadrant of the axes (or figure):
A 2-tuple (x, y) places the corner of the legend specified by loc at x, y. For example, to put the legend's upper right-hand corner in the center of the axes (or figure) the following keywords can be used:
The number of columns that the legend has.
The font properties of the legend. If None (default), the current matplotlib.rcParams will be used.
The font size of the legend. If the value is numeric the size will be the absolute font size in points. String values are relative to the current default font size. This argument is only used if prop is not specified.
The color of the text in the legend. Either a valid color string (for example, 'red'), or a list of color strings. The labelcolor can also be made to match the color of the line or marker using 'linecolor', 'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec').
Labelcolor can be set globally using rcParams["legend.labelcolor"] (default: 'None'). If None, use rcParams["text.color"] (default: 'black').
The number of marker points in the legend when creating a legend entry for a Line2D (line).
The number of marker points in the legend when creating a legend entry for a PathCollection (scatter plot).
The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. 0.0 is at the base the legend text, and 1.0 is at the top. To draw all markers at the same height, set to [0.5].
The relative size of legend markers compared with the originally drawn ones.
If True, legend marker is placed to the left of the legend label. If False, legend marker is placed to the right of the legend label.
Whether the legend should be drawn on a patch (frame).
Whether round edges should be enabled around the FancyBboxPatch which makes up the legend's background.
Whether to draw a shadow behind the legend.
The alpha transparency of the legend's background. If shadow is activated and framealpha is None, the default value is ignored.
The legend's background color. If "inherit", use rcParams["axes.facecolor"] (default: 'white').
The legend's background patch edge color. If "inherit", use take rcParams["axes.edgecolor"] (default: 'black').
If mode is set to "expand" the legend will be horizontally expanded to fill the axes area (or bbox_to_anchor if defines the legend's size).
The transform for the bounding box (bbox_to_anchor). For a value of None (default) the Axes' transAxes transform will be used.
The legend's title. Default is no title (None).
The font properties of the legend's title. If None (default), the title_fontsize argument will be used if present; if title_fontsize is also None, the current rcParams["legend.title_fontsize"] (default: None) will be used.
The font size of the legend's title. Note: This cannot be combined with title_fontproperties. If you want to set the fontsize alongside other font properties, use the size parameter in title_fontproperties.
The fractional whitespace inside the legend border, in font-size units.
The vertical space between the legend entries, in font-size units.
The length of the legend handles, in font-size units.
The height of the legend handles, in font-size units.
The pad between the legend handle and text, in font-size units.
The pad between the axes and legend border, in font-size units.
The spacing between columns, in font-size units.
The custom dictionary mapping instances or types to a legend handler. This handler_map updates the default handler map found at matplotlib.legend.Legend.get_legend_handler_map.
Users can specify any arbitrary location for the legend using the bbox_to_anchor keyword argument. bbox_to_anchor can be a BboxBase (or derived there from) or a tuple of 2 or 4 floats. See set_bbox_to_anchor for more detail.
The legend location can be specified by setting loc with a tuple of 2 floats, which is interpreted as the lower-left corner of the legend in the normalized axes coordinate.
Test whether the artist contains the mouse event.
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.
Set whether the legend box patch is drawn.
Return the bbox that the legend will be anchored to.
Return a list of the child Artists of this Artist.
A class method that returns the default handler map.
Return True if the legend is draggable, False otherwise.
Return the Rectangle used to frame the legend.
Get whether the legend box patch is drawn.
Return a legend handler from legend_handler_map that corresponds to orig_handler.
legend_handler_map should be a dictionary object (that is returned by the get_legend_handler_map method).
It first checks if the orig_handle itself is a key in the legend_handler_map and return the associated value. Otherwise, it checks for each of the classes in its method-resolution-order. If no matching key is found, it returns None.
Return the handler map.
Return the list of Line2Ds in the legend.
Return the list of Patchs in the legend.
Return the list of Texts in the legend.
Like Artist.get_window_extent, but includes any clipping.
renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())
The enclosing bounding box (in figure pixel coordinates).
Return the Text instance for the legend title.
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
bbox_to_anchor
BboxBase or tuple
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
draggable
bool
figure
Figure
frame_on
bool
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
title
unknown
transform
Transform
url
str
visible
bool
zorder
float
Set the bbox that the legend will be anchored to.
The bounding box can be specified in the following ways:
A transform to apply to the bounding box. If not specified, this will use a transform to the bounding box of the parent.
A class method to set the default handler map.
Enable or disable mouse dragging support of the legend.
Whether mouse dragging is enabled.
Use blitting for faster image composition. For details see FuncAnimation.
The legend parameter to be changed when dragged:
If state is True this returns the DraggableLegend helper instance. Otherwise this returns None.
Set whether the legend box patch is drawn.
Set the legend title. Fontproperties can be optionally set with prop parameter.
A class method to update the default handler map.


Bases: matplotlib.offsetbox.DraggableOffsetBox
Wrapper around a Legend to support mouse dragging.
The Legend instance to wrap.
Use blitting for faster image composition. For details see FuncAnimation.
If "loc", update the loc parameter of the legend upon finalizing. If "bbox", update the bbox_to_anchor parameter.


Bases: matplotlib.artist.Artist
Place a legend on the axes at location loc.
The artist that contains the legend.
A list of Artists (lines, patches) to be added to the legend.
A list of labels to show next to the artists. The length of handles and labels should be the same. If they are not, they are truncated to the smaller of both lengths.
The location of the legend.
The strings 'upper left', 'upper right', 'lower left', 'lower right' place the legend at the corresponding corner of the axes/figure.
The strings 'upper center', 'lower center', 'center left', 'center right' place the legend at the center of the corresponding edge of the axes/figure.
The string 'center' places the legend at the center of the axes/figure.
The string 'best' places the legend at the location, among the nine locations defined so far, with the minimum overlap with other drawn artists. This option can be quite slow for plots with large amounts of data; your plotting speed may benefit from providing a specific location.
The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in axes coordinates (in which case bbox_to_anchor will be ignored).
For back-compatibility, 'center right' (but no other location) can also be spelled 'right', and each "string" locations can also be given as a numeric value:
Location String
Location Code
'best'
0
'upper right'
1
'upper left'
2
'lower left'
3
'lower right'
4
'right'
5
'center left'
6
'center right'
7
'lower center'
8
'upper center'
9
'center'
10
Box that is used to position the legend in conjunction with loc. Defaults to axes.bbox (if called as a method to Axes.legend) or figure.bbox (if Figure.legend). This argument allows arbitrary placement of the legend.
Bbox coordinates are interpreted in the coordinate system given by bbox_transform, with the default transform Axes or Figure coordinates, depending on which legend is called.
If a 4-tuple or BboxBase is given, then it specifies the bbox (x, y, width, height) that the legend is placed in. To put the legend in the best location in the bottom right quadrant of the axes (or figure):
A 2-tuple (x, y) places the corner of the legend specified by loc at x, y. For example, to put the legend's upper right-hand corner in the center of the axes (or figure) the following keywords can be used:
The number of columns that the legend has.
The font properties of the legend. If None (default), the current matplotlib.rcParams will be used.
The font size of the legend. If the value is numeric the size will be the absolute font size in points. String values are relative to the current default font size. This argument is only used if prop is not specified.
The color of the text in the legend. Either a valid color string (for example, 'red'), or a list of color strings. The labelcolor can also be made to match the color of the line or marker using 'linecolor', 'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec').
Labelcolor can be set globally using rcParams["legend.labelcolor"] (default: 'None'). If None, use rcParams["text.color"] (default: 'black').
The number of marker points in the legend when creating a legend entry for a Line2D (line).
The number of marker points in the legend when creating a legend entry for a PathCollection (scatter plot).
The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. 0.0 is at the base the legend text, and 1.0 is at the top. To draw all markers at the same height, set to [0.5].
The relative size of legend markers compared with the originally drawn ones.
If True, legend marker is placed to the left of the legend label. If False, legend marker is placed to the right of the legend label.
Whether the legend should be drawn on a patch (frame).
Whether round edges should be enabled around the FancyBboxPatch which makes up the legend's background.
Whether to draw a shadow behind the legend.
The alpha transparency of the legend's background. If shadow is activated and framealpha is None, the default value is ignored.
The legend's background color. If "inherit", use rcParams["axes.facecolor"] (default: 'white').
The legend's background patch edge color. If "inherit", use take rcParams["axes.edgecolor"] (default: 'black').
If mode is set to "expand" the legend will be horizontally expanded to fill the axes area (or bbox_to_anchor if defines the legend's size).
The transform for the bounding box (bbox_to_anchor). For a value of None (default) the Axes' transAxes transform will be used.
The legend's title. Default is no title (None).
The font properties of the legend's title. If None (default), the title_fontsize argument will be used if present; if title_fontsize is also None, the current rcParams["legend.title_fontsize"] (default: None) will be used.
The font size of the legend's title. Note: This cannot be combined with title_fontproperties. If you want to set the fontsize alongside other font properties, use the size parameter in title_fontproperties.
The fractional whitespace inside the legend border, in font-size units.
The vertical space between the legend entries, in font-size units.
The length of the legend handles, in font-size units.
The height of the legend handles, in font-size units.
The pad between the legend handle and text, in font-size units.
The pad between the axes and legend border, in font-size units.
The spacing between columns, in font-size units.
The custom dictionary mapping instances or types to a legend handler. This handler_map updates the default handler map found at matplotlib.legend.Legend.get_legend_handler_map.
Users can specify any arbitrary location for the legend using the bbox_to_anchor keyword argument. bbox_to_anchor can be a BboxBase (or derived there from) or a tuple of 2 or 4 floats. See set_bbox_to_anchor for more detail.
The legend location can be specified by setting loc with a tuple of 2 floats, which is interpreted as the lower-left corner of the legend in the normalized axes coordinate.
Test whether the artist contains the mouse event.
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.
Set whether the legend box patch is drawn.
Return the bbox that the legend will be anchored to.
Return a list of the child Artists of this Artist.
A class method that returns the default handler map.
Return True if the legend is draggable, False otherwise.
Return the Rectangle used to frame the legend.
Get whether the legend box patch is drawn.
Return a legend handler from legend_handler_map that corresponds to orig_handler.
legend_handler_map should be a dictionary object (that is returned by the get_legend_handler_map method).
It first checks if the orig_handle itself is a key in the legend_handler_map and return the associated value. Otherwise, it checks for each of the classes in its method-resolution-order. If no matching key is found, it returns None.
Return the handler map.
Return the list of Line2Ds in the legend.
Return the list of Patchs in the legend.
Return the list of Texts in the legend.
Like Artist.get_window_extent, but includes any clipping.
renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())
The enclosing bounding box (in figure pixel coordinates).
Return the Text instance for the legend title.
Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
bbox_to_anchor
BboxBase or tuple
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
draggable
bool
figure
Figure
frame_on
bool
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
title
unknown
transform
Transform
url
str
visible
bool
zorder
float
Set the bbox that the legend will be anchored to.
The bounding box can be specified in the following ways:
A transform to apply to the bounding box. If not specified, this will use a transform to the bounding box of the parent.
A class method to set the default handler map.
Enable or disable mouse dragging support of the legend.
Whether mouse dragging is enabled.
Use blitting for faster image composition. For details see FuncAnimation.
The legend parameter to be changed when dragged:
If state is True this returns the DraggableLegend helper instance. Otherwise this returns None.
Set whether the legend box patch is drawn.
Set the legend title. Fontproperties can be optionally set with prop parameter.
A class method to update the default handler map.


Test whether the artist contains the mouse event.
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.


Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.


Set whether the legend box patch is drawn.


Return the bbox that the legend will be anchored to.


Return a list of the child Artists of this Artist.


A class method that returns the default handler map.


Return True if the legend is draggable, False otherwise.


Return the Rectangle used to frame the legend.


Get whether the legend box patch is drawn.


Return a legend handler from legend_handler_map that corresponds to orig_handler.
legend_handler_map should be a dictionary object (that is returned by the get_legend_handler_map method).
It first checks if the orig_handle itself is a key in the legend_handler_map and return the associated value. Otherwise, it checks for each of the classes in its method-resolution-order. If no matching key is found, it returns None.


Return the list of Line2Ds in the legend.


Return the list of Patchs in the legend.


Like Artist.get_window_extent, but includes any clipping.
renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())
The enclosing bounding box (in figure pixel coordinates).


Return the Text instance for the legend title.


Get the artist's bounding box in display space.
The bounding box' width and height are nonnegative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
bbox_to_anchor
BboxBase or tuple
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
draggable
bool
figure
Figure
frame_on
bool
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
title
unknown
transform
Transform
url
str
visible
bool
zorder
float


Set the bbox that the legend will be anchored to.
The bounding box can be specified in the following ways:
A transform to apply to the bounding box. If not specified, this will use a transform to the bounding box of the parent.


A class method to set the default handler map.


Enable or disable mouse dragging support of the legend.
Whether mouse dragging is enabled.
Use blitting for faster image composition. For details see FuncAnimation.
The legend parameter to be changed when dragged:
If state is True this returns the DraggableLegend helper instance. Otherwise this returns None.


Set whether the legend box patch is drawn.


Set the legend title. Fontproperties can be optionally set with prop parameter.


A class method to update the default handler map.


Default legend handlers.
Important
This is a low-level legend API, which most end users do not need.
We recommend that you are familiar with the legend guide before reading this documentation.
Legend handlers are expected to be a callable object with a following signature.
Where legend is the legend itself, orig_handle is the original plot, fontsize is the fontsize in pixels, and handlebox is a OffsetBox instance. Within the call, you should create relevant artists (using relevant properties from the legend and/or orig_handle) and add them into the handlebox. The artists needs to be scaled according to the fontsize (note that the size is in pixel, i.e., this is dpi-scaled value).
This module includes definition of several legend handler classes derived from the base class (HandlerBase) with the following method:
A Base class for default legend handlers.
The derived classes are meant to override create_artists method, which has a following signature.:
The overridden method needs to create artists of the given transform that fits in the given dimension (xdescent, ydescent, width, height) that are scaled by fontsize if necessary.
Return the artist that this HandlerBase generates for the given original artist/handle.
The legend for which these legend artists are being created.
The object for which these legend artists are being created.
The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.
Handler for CircleCollections.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for Errorbars.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for Line2D instances.
See also
An earlier handler implementation, which used one artist for the line and another for the marker(s).
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Original handler for Line2D instances, that relies on combining a line-only with a marker-only artist. May be deprecated in the future.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for LineCollection instances.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.
A legend handler that shows numpoints points in the legend entry.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerBase.
A legend handler that shows numpoints in the legend, and allows them to be individually offset in the y-direction.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for Patch instances.
The function that creates the legend key artist. patch_func should have the signature:
Subsequently the created artist will have its update_prop method called and the appropriate transform will be applied.
Keyword arguments forwarded to HandlerBase.
Handler for PathCollections, which are used by scatter.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for PolyCollection used in fill_between and stackplot.
Handler for RegularPolyCollections.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpoints.
Handler for plots produced by stem.
Padding between points in legend entry.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpointsYoffsets.
Handler for StepPatch instances.
Handler for Tuple.
The number of sections to divide the legend area into. If None, use the length of the input tuple.
Padding in units of fraction of font size.
Keyword arguments forwarded to HandlerBase.


A Base class for default legend handlers.
The derived classes are meant to override create_artists method, which has a following signature.:
The overridden method needs to create artists of the given transform that fits in the given dimension (xdescent, ydescent, width, height) that are scaled by fontsize if necessary.
Return the artist that this HandlerBase generates for the given original artist/handle.
The legend for which these legend artists are being created.
The object for which these legend artists are being created.
The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.


Return the artist that this HandlerBase generates for the given original artist/handle.
The legend for which these legend artists are being created.
The object for which these legend artists are being created.
The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.


Handler for CircleCollections.
Number of points to show in legend entry.
Length numpoints list of y offsets for each point in legend entry.
Keyword arguments forwarded to HandlerNpoints.


Handler for Errorbars.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.


Handler for Line2D instances.
See also
An earlier handler implementation, which used one artist for the line and another for the marker(s).
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.


Original handler for Line2D instances, that relies on combining a line-only with a marker-only artist. May be deprecated in the future.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.


Handler for LineCollection instances.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerNpoints.


A legend handler that shows numpoints points in the legend entry.
Padding between points in legend entry.
Number of points to show in legend entry.
Keyword arguments forwarded to HandlerBase.