Plot the cross-spectral density.
The cross spectral density \(P_{xy}\) by Welch's average periodogram method. The vectors x and y are divided into NFFT length segments. Each segment is detrended by function detrend and windowed by function window. noverlap gives the length of the overlap between segments. The product of the direct FFTs of x and y are averaged over each segment to compute \(P_{xy}\), with a scaling to correct for power loss due to windowing.
If len(x) < NFFT or len(y) < NFFT, they will be zero padded to NFFT.
Arrays or sequences containing the data.
The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit.
A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.
Which sides of the spectrum to return. 'default' is one-sided for real data and two-sided for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.
The number of points to which the data segment is padded when performing the FFT. This can be different from NFFT, which specifies the number of data points used. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to NFFT
The number of data points used in each block for the FFT. A power 2 is most efficient. This should NOT be used to get zero padding, or the scaling of the result will be incorrect; use pad_to for this instead.
The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the detrend parameter is a vector, in Matplotlib it is a function. The mlab module defines detrend_none, detrend_mean, and detrend_linear, but you can use a custom function as well. You can also use a string to choose one of the functions: 'none' calls detrend_none. 'mean' calls detrend_mean. 'linear' calls detrend_linear.
Whether the resulting density values should be scaled by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MATLAB compatibility.
The number of points of overlap between segments.
The center frequency of x, which offsets the x extents of the plot to reflect the frequency range used when a signal is acquired and then filtered and downsampled to baseband.
Whether to include the line object plotted in the returned values.
The values for the cross spectrum \(P_{xy}\) before scaling (complex valued).
The frequencies corresponding to the elements in Pxy.
The line created by this function. Only returned if return_line is True.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y
Keyword arguments control the Line2D properties:
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
antialiased or aa
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
dash_capstyle
CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
dashes
sequence of floats (on/off ink in points) or (None, None)
data
(2, N) array or two 1D arrays
drawstyle or ds
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure
Figure
fillstyle
{'full', 'left', 'right', 'bottom', 'top', 'none'}
gid
str
in_layout
bool
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float
marker
marker style string, Path or MarkerStyle
markeredgecolor or mec
color
markeredgewidth or mew
float
markerfacecolor or mfc
color
markerfacecoloralt or mfcalt
color
markersize or ms
float
markevery
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects
AbstractPathEffect
picker
float or callable[[Artist, Event], tuple[bool, dict]]
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
solid_capstyle
CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
transform
unknown
url
str
visible
bool
xdata
1D array
ydata
1D array
zorder
float
See also
is equivalent to setting y = x.
For plotting, the power is plotted as \(10 \log_{10}(P_{xy})\) for decibels, though \(P_{xy}\) itself is returned.
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)
CSD Demo


Called when the mouse moves during a pan operation.
The pressed mouse button.
The pressed key, if any.
The mouse coordinates in display coords.
This is intended to be overridden by new projection types.


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.


Efficiently redraw a single artist.
This method can only be used after an initial draw of the figure, because that creates and caches the renderer needed here.
Faster rendering by using blitting


Called when a pan operation completes (when the mouse button is up.)
This is intended to be overridden by new projection types.


Plot y versus x as lines and/or markers with attached errorbars.
x, y define the data locations, xerr, yerr define the errorbar sizes. By default, this draws the data markers/lines as well the errorbars. Use fmt='none' to draw errorbars without any data markers.
The data positions.
The errorbar sizes:
Note that all error arrays should have positive values.
See Different ways of specifying error bars for an example on the usage of xerr and yerr.
The format for the data points / data lines. See plot for details.
Use 'none' (case insensitive) to plot errorbars without any data markers.
The color of the errorbar lines. If None, use the color of the line connecting the markers.
The linewidth of the errorbar lines. If None, the linewidth of the current style is used.
The length of the error bar caps in points.
An alias to the keyword argument markeredgewidth (a.k.a. mew). This setting is a more sensible name for the property that controls the thickness of the error bar cap in points. For backwards compatibility, if mew or markeredgewidth are given, then they will over-ride capthick. This may change in future releases.
If True, will plot the errorbars above the plot symbols. Default is below.
These arguments can be used to indicate that a value gives only upper/lower limits. In that case a caret symbol is used to indicate this. lims-arguments may be scalars, or array-likes of the same length as xerr and yerr. To use limits with inverted axes, set_xlim or set_ylim must be called before errorbar(). Note the tricky parameter names: setting e.g. lolims to True means that the y-value is a lower limit of the True value, so, only an upward-pointing arrow will be drawn!
draws error bars on a subset of the data. errorevery =N draws error bars on the points (x[::N], y[::N]). errorevery =(start, N) draws error bars on the points (x[start::N], y[start::N]). e.g. errorevery=(6, 3) adds error bars to the data at (x[6], x[9], x[12], x[15], ...). Used to avoid overlapping error bars when two series share x-axis values.
The container contains:
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y, xerr, yerr
All other keyword arguments are passed on to the plot call drawing the markers. For example, this code makes big red squares with thick green edges:
where mfc, mec, ms and mew are aliases for the longer property names, markerfacecolor, markeredgecolor, markersize and markeredgewidth.
Valid kwargs for the marker properties are Line2D properties:
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
antialiased or aa
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
dash_capstyle
CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
dashes
sequence of floats (on/off ink in points) or (None, None)
data
(2, N) array or two 1D arrays
drawstyle or ds
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure
Figure
fillstyle
{'full', 'left', 'right', 'bottom', 'top', 'none'}
gid
str
in_layout
bool
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float
marker
marker style string, Path or MarkerStyle
markeredgecolor or mec
color
markeredgewidth or mew
float
markerfacecolor or mfc
color
markerfacecoloralt or mfcalt
color
markersize or ms
float
markevery
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects
AbstractPathEffect
picker
float or callable[[Artist, Event], tuple[bool, dict]]
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
solid_capstyle
CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
transform
unknown
url
str
visible
bool
xdata
1D array
ydata
1D array
zorder
float
Errorbar subsampling
Errorbar function
Different ways of specifying error bars
Including upper and lower limits in error bars
Creating boxes from error bars using PatchCollection
Legend Demo
Parasite Simple2
3D errorbars
Log Demo
errorbar(x, y, yerr, xerr)


Plot identical parallel lines at the given positions.
This type of plot is commonly used in neuroscience for representing neural events, where it is usually called a spike raster, dot raster, or raster plot.
However, it is useful in any situation where you wish to show the timing or position of multiple sets of discrete events, such as the arrival times of people to a business on each day of the month or the date of hurricanes each year of the last century.
A 1D array-like defines the positions of one sequence of events.
Multiple groups of events may be passed as a list of array-likes. Each group can be styled independently by passing lists of values to lineoffsets, linelengths, linewidths, colors and linestyles.
Note that positions can be a 2D array, but in practice different event groups usually have different counts so that one will use a list of different-length arrays rather than a 2D array.
The direction of the event sequence:
The offset of the center of the lines from the origin, in the direction orthogonal to orientation.
If positions is 2D, this can be a sequence with length matching the length of positions.
The total height of the lines (i.e. the lines stretches from lineoffset - linelength/2 to lineoffset + linelength/2).
If positions is 2D, this can be a sequence with length matching the length of positions.
The line width(s) of the event lines, in points.
If positions is 2D, this can be a sequence with length matching the length of positions.
The color(s) of the event lines.
If positions is 2D, this can be a sequence with length matching the length of positions.
Default is 'solid'. Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:
where onoffseq is an even length tuple of on and off ink in points.
If positions is 2D, this can be a sequence with length matching the length of positions.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
positions, lineoffsets, linelengths, linewidths, colors, linestyles
Other keyword arguments are line collection properties. See LineCollection for a list of the valid properties.
The EventCollection that were added.
For linelengths, linewidths, colors, and linestyles, if only a single value is given, that value is applied to all lines. If an array-like is given, it must have the same length as positions, and each value will be applied to the corresponding row of the array.
(Source code, png, pdf)
eventplot(D)


Plot filled polygons.
Each polygon is defined by the lists of x and y positions of its nodes, optionally followed by a color specifier. See matplotlib.colors for supported color specifiers. The standard color cycle is used for polygons without a color specifier.
You can plot multiple polygons by providing multiple x, y, [color] groups.
For example, each of the following is legal:
An object with labelled data. If given, provide the label names to plot in x and y, e.g.:
Use fill_between() if you would like to fill the region between two curves.
Filled polygon
Radar chart (aka spider or star chart)
Ellipse With Units


Fill the area between two horizontal curves.
The curves are defined by the points (x, y1) and (x, y2). This creates one or multiple polygons describing the filled area.
You may exclude some horizontal sections from filling using where.
By default, the edges connect the given points directly. Use step if the filling should be a step function, i.e. constant in between x.
The x coordinates of the nodes defining the curves.
The y coordinates of the nodes defining the first curve.
The y coordinates of the nodes defining the second curve.
Define where to exclude some horizontal regions from being filled. The filled regions are defined by the coordinates x[where]. More precisely, fill between x[i] and x[i+1] if where[i] and where[i+1]. Note that this definition implies that an isolated True value between two False values in where will not result in filling. Both sides of the True position remain unfilled due to the adjacent False values.
This option is only relevant if where is used and the two curves are crossing each other.
Semantically, where is often used for y1 > y2 or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the x array. Such a polygon cannot describe the above semantics close to the intersection. The x-sections containing the intersection are simply clipped.
Setting interpolate to True will calculate the actual intersection point and extend the filled region up to this point.
Define step if the filling should be a step function, i.e. constant in between x. The value determines where the step will occur:
A PolyCollection containing the plotted polygons.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y1, y2, where
All other keyword arguments are passed on to PolyCollection. They control the Polygon properties:
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
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
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
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
See also
Fill between two sets of y-values.
Fill between two sets of x-values.
Fill Between and Alpha
Filling the area between lines
fill_between(x, y1, y2)


Fill the area between two vertical curves.
The curves are defined by the points (y, x1) and (y, x2). This creates one or multiple polygons describing the filled area.
You may exclude some vertical sections from filling using where.
By default, the edges connect the given points directly. Use step if the filling should be a step function, i.e. constant in between y.
The y coordinates of the nodes defining the curves.
The x coordinates of the nodes defining the first curve.
The x coordinates of the nodes defining the second curve.
Define where to exclude some vertical regions from being filled. The filled regions are defined by the coordinates y[where]. More precisely, fill between y[i] and y[i+1] if where[i] and where[i+1]. Note that this definition implies that an isolated True value between two False values in where will not result in filling. Both sides of the True position remain unfilled due to the adjacent False values.
This option is only relevant if where is used and the two curves are crossing each other.
Semantically, where is often used for x1 > x2 or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the y array. Such a polygon cannot describe the above semantics close to the intersection. The y-sections containing the intersection are simply clipped.
Setting interpolate to True will calculate the actual intersection point and extend the filled region up to this point.
Define step if the filling should be a step function, i.e. constant in between y. The value determines where the step will occur:
A PolyCollection containing the plotted polygons.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
y, x1, x2, where
All other keyword arguments are passed on to PolyCollection. They control the Polygon properties:
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
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
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
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
See also
Fill between two sets of y-values.
Fill between two sets of x-values.
Fill Betweenx Demo


Find artist objects.
Recursively find all Artist instances contained in the artist.
A filter criterion for the matches. This can be
Include self in the list to be checked for a match.


Return a format string formatting the x, y coordinates.


Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar's formatter.
See also


Return x formatted as an x-value.
This function will use the fmt_xdata attribute if it is not None, else will fall back on the xaxis major formatter.


Return y formatted as an y-value.
This function will use the fmt_ydata attribute if it is not None, else will fall back on the yaxis major formatter.


Return whether the Axes will adjust its physical dimension ('box') or its data limits ('datalim') to achieve the desired aspect ratio.
See also
Set how the Axes adjusts to achieve the required aspect ratio.
For a description of aspect handling.


Get the anchor location.
See also
for a description of the anchor.
for a description of aspect handling.


Return the aspect ratio of the axes scaling.
This is either "auto" or a float giving the ratio of y/x-scale.


Return True if each axis is autoscaled, False otherwise.


Return whether the x-axis is autoscaled.


Return whether the y-axis is autoscaled.


Get whether axis ticks and gridlines are above or below most artists.
See also


Return the Axes box aspect, i.e. the ratio of height to width.
The box aspect is None (i.e. chosen depending on the available figure space) unless explicitly specified.
See also
for a description of box aspect.
for a description of aspect handling.


Return a list of the child Artists of this Artist.


Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that format_cursor_data can convert the data to a string representation.
The only current use case is displaying the z-value of an AxesImage in the status bar of a plot window, while moving the mouse.
See also


Return the aspect ratio of the scaled data.
This method is intended to be overridden by new projection types.


Return a default list of artists that are used for the bounding box calculation.
Artists are excluded either by not being visible or artist.set_in_layout(False).


Get whether the Axes rectangle patch is drawn.


Return a list of AxesImages contained by the Axes.


Return the Legend instance, or None if no legend is defined.


Return handles and labels for legend
ax.legend() is equivalent to
Legend guide


Return a list of lines contained by the Axes.


Get whether the Axes responds to navigation commands.


Get the navigation toolbar button status: 'PAN', 'ZOOM', or None.


Return the position of the Axes within the figure as a Bbox.
If True, return the original position. Otherwise return the active position. For an explanation of the positions see set_position.
Contour Demo


Return the zorder value below which artists will be rasterized.


Return a reference to the shared axes Grouper object for x axes.


Return a reference to the shared axes Grouper object for y axes.


Return the tight bounding box of the axes, including axis and their decorators (xlabel, title, etc).
Artists that have artist.set_in_layout(False) are not included in the bbox.
renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())
List of artists to include in the tight bounding box. If None (default), then all artist children of the Axes are included in the tight bounding box.
If call_axes_locator is False, it does not call the _axes_locator attribute, which is necessary to get the correct bounding box. call_axes_locator=False can be used if the caller is only interested in the relative size of the tightbbox compared to the Axes bbox.
The bounding box will not include the x-extent of the title and the xlabel, or the y-extent of the ylabel.
Bounding box in figure pixel coordinates.
See also


Get an Axes title.
Get one of the three available Axes titles. The available titles are positioned above the Axes in the center, flush with the left edge, and flush with the right edge.
Which title to return.
The title text string.


Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.


Return the Axes bounding box in display space; args and kwargs are empty.
This bounding box does not include the spines, ticks, ticklables, or other labels. For a bounding box including these elements use get_tightbbox.
See also


Return the XAxis instance.
The use of this function is discouraged. You should instead directly access the attribute ax.xaxis.


The transform used for drawing x-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates
The text vertical alignment.
The text horizontal alignment.
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.


The transform used for drawing secondary x-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates
The text vertical alignment.
The text horizontal alignment.
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.


Get the transformation used for drawing x-axis labels, ticks and gridlines. The x-direction is in data coordinates and the y-direction is in axis coordinates.
Note
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.
Filling the area between lines
hlines and vlines
Boxplots
Scale invariant angle label
Centered spines with arrows
Transformations Tutorial


Return the lower and upper x-axis bounds, in increasing order.
See also


Return the xaxis' grid lines as a list of Line2Ds.


Return the x-axis view limits.
The current x-axis limits in data coordinates.
See also
The x-axis may be inverted, in which case the left value will be greater than the right value.
Decay


Return the xaxis' major tick labels, as a list of Text.


Return the xaxis' minor tick labels, as a list of Text.


Get the xaxis' tick labels.
Whether to return the minor or the major ticklabels.
Overrides minor.
Selects which ticklabels to return
The tick label strings are not populated until a draw method has been called.
See also: draw and draw.
Creating a timeline with lines, dates, and text
Creating annotated heatmaps
Aligning Labels
Boxplots
Date tick labels
Formatting date ticks using ConciseDateFormatter
Evans test
The Lifecycle of a Plot


Return the xaxis' tick lines as a list of Line2Ds.


Return the xaxis' tick locations in data coordinates.


Return the YAxis instance.
The use of this function is discouraged. You should instead directly access the attribute ax.yaxis.


The transform used for drawing y-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates
The text vertical alignment.
The text horizontal alignment.
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.


The transform used for drawing secondart y-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates
The text vertical alignment.
The text horizontal alignment.
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.


Get the transformation used for drawing y-axis labels, ticks and gridlines. The x-direction is in axis coordinates and the y-direction is in data coordinates.
Note
This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.
Centered spines with arrows
Connect Simple01
Transformations Tutorial


Return the lower and upper y-axis bounds, in increasing order.
See also


Return the yaxis' grid lines as a list of Line2Ds.


Return the y-axis view limits.
The current y-axis limits in data coordinates.
See also
The y-axis may be inverted, in which case the bottom value will be greater than the top value.
Line, Poly and RegularPoly Collection with autoscaling


Return the yaxis' major tick labels, as a list of Text.


Return the yaxis' minor tick labels, as a list of Text.


Get the yaxis' tick labels.
Whether to return the minor or the major ticklabels.
Overrides minor.
Selects which ticklabels to return
The tick label strings are not populated until a draw method has been called.
See also: draw and draw.
Fill Between and Alpha
Programmatically controlling subplot adjustment


Return the yaxis' tick lines as a list of Line2Ds.


Return the yaxis' tick locations in data coordinates.


Configure the grid lines.
Whether to show the grid lines. If any kwargs are supplied, it is assumed you want the grid on and visible will be set to True.
If visible is None and there are no kwargs, this toggles the visibility of the lines.
The grid lines to apply the changes on.
The axis to apply the changes on.
Define the line properties of the grid, e.g.:
Valid keyword arguments 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
antialiased or aa
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
dash_capstyle
CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
dashes
sequence of floats (on/off ink in points) or (None, None)
data
(2, N) array or two 1D arrays
drawstyle or ds
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure
Figure
fillstyle
{'full', 'left', 'right', 'bottom', 'top', 'none'}
gid
str
in_layout
bool
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float
marker
marker style string, Path or MarkerStyle
markeredgecolor or mec
color
markeredgewidth or mew
float
markerfacecolor or mfc
color
markerfacecoloralt or mfcalt
color
markersize or ms
float
markevery
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects
AbstractPathEffect
picker
float or callable[[Artist, Event], tuple[bool, dict]]
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
solid_capstyle
CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
transform
unknown
url
str
visible
bool
xdata
1D array
ydata
1D array
zorder
float
The axis is drawn as a unit, so the effective zorder for drawing the grid is determined by the zorder of each axis, not by the zorder of the Line2D objects comprising the grid. Therefore, to set grid zorder, use set_axisbelow or, for more control, call the set_zorder method of each axis.
Broken Barh
CSD Demo
Fill Between and Alpha
Psd Demo
Scatter Demo2
Scatter plots with a legend
Simple Plot
Cross- and Auto-Correlation Demo
Contour Corner Mask
Creating annotated heatmaps
Image Demo
Watermark image
Axes Props
Figure labels: suptitle, supxlabel, supylabel
Invert Axes
Using histograms to plot a cumulative distribution
Polar plot
Date tick labels
Multiline
Text watermark
PathPatch object
Anatomy of a figure
Bachelor's degrees by gender
Decay
The double pendulum problem
Custom projection
Patheffect Demo
Pythonic Matplotlib
2D and 3D Axes in same Figure
Log Demo
Log Axis
Scales
Symlog Demo
Artist tests
Basic Usage


Return whether any artists have been added to the Axes.
This should not be used to determine whether the dataLim need to be updated, and may not actually be useful for anything.


Return whether units are set on any axis.


Make a 2D hexagonal binning plot of points x, y.
If C is None, the value of the hexagon is determined by the number of points in the hexagon. Otherwise, C specifies values at the coordinate (x[i], y[i]). For each hexagon, these values are reduced using reduce_C_function.
The data positions. x and y must be of the same length.
If given, these values are accumulated in the bins. Otherwise, every point has a value of 1. Must be of the same length as x and y.
If a single int, the number of hexagons in the x-direction. The number of hexagons in the y-direction is chosen such that the hexagons are approximately regular.
Alternatively, if a tuple (nx, ny), the number of hexagons in the x-direction and the y-direction.
Discretization of the hexagon values.
Use a linear or log10 scale on the horizontal axis.
Use a linear or log10 scale on the vertical axis.
If not None, only display cells with more than mincnt number of points in the cell.
If marginals is True, plot the marginal density as colormapped rectangles along the bottom of the x-axis and left of the y-axis.
The limits of the bins (xmin, xmax, ymin, ymax). The default assigns the limits based on gridsize, x, y, xscale and yscale.
If xscale or yscale is set to 'log', the limits are expected to be the exponent for a power of 10. E.g. for x-limits of 1 and 50 in 'linear' scale and y-limits of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3).
A PolyCollection defining the hexagonal bins.
If marginals is True, horizontal bar and vertical bar (both PolyCollections) will be attached to the return collection as attributes hbar and vbar.
The Colormap instance or registered colormap name used to map the bin values to colors.
The Normalize instance scales the bin values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
The colorbar range. If None, suitable min/max values are automatically chosen by the Normalize instance (defaults to the respective min/max values of the bins in case of the default linear scaling). It is an error to use vmin/vmax when norm is given.
The alpha blending value, between 0 (transparent) and 1 (opaque).
If None, defaults to 1.0.
The color of the hexagon edges. Possible values are:
The function to aggregate C within the bins. It is ignored if C is not given. This must have the signature:
Commonly used functions are:
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y, C
All other keyword arguments are passed on to PolyCollection:
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
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
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
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
See also
2D histogram rectangular bins
Hexagonal binned plot
hexbin(x, y, C)


Plot a histogram.
Compute and draw the histogram of x. The return value is a tuple (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1, ...]) if the input contains multiple data. See the documentation of the weights parameter to draw a histogram of already-binned data.
Multiple data can be provided via x as a list of datasets of potentially different length ([x0, x1, ...]), or as a 2D ndarray in which each column is a dataset. Note that the ndarray form is transposed relative to the list form.
Masked arrays are not supported.
The bins, range, weights, and density parameters behave as in numpy.histogram.
Input values, this takes either a single array or a sequence of arrays which are not required to be of the same length.
If bins is an integer, it defines the number of equal-width bins in the range.
If bins is a sequence, it defines the bin edges, including the left edge of the first bin and the right edge of the last bin; in this case, bins may be unequally spaced. All but the last (righthand-most) bin is half-open. In other words, if bins is:
then the first bin is [1, 2) (including 1, but excluding 2) and the second [2, 3). The last bin, however, is [3, 4], which includes 4.
If bins is a string, it is one of the binning strategies supported by numpy.histogram_bin_edges: 'auto', 'fd', 'doane', 'scott', 'stone', 'rice', 'sturges', or 'sqrt'.
The lower and upper range of the bins. Lower and upper outliers are ignored. If not provided, range is (x.min(), x.max()). Range has no effect if bins is a sequence.
If bins is a sequence or range is specified, autoscaling is based on the specified bin range instead of the range of x.
If True, draw and return a probability density: each bin will display the bin's raw count divided by the total number of counts and the bin width (density = counts / (sum(counts) * np.diff(bins))), so that the area under the histogram integrates to 1 (np.sum(density * np.diff(bins)) == 1).
If stacked is also True, the sum of the histograms is normalized to 1.
An array of weights, of the same shape as x. Each value in x only contributes its associated weight towards the bin count (instead of 1). If density is True, the weights are normalized, so that the integral of the density over the range remains 1.
This parameter can be used to draw a histogram of data that has already been binned, e.g. using numpy.histogram (by treating each bin as a single point with a weight equal to its count)
(or you may alternatively use bar()).
If True, then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. The last bin gives the total number of datapoints.
If density is also True then the histogram is normalized such that the last bin equals 1.
If cumulative is a number less than 0 (e.g., -1), the direction of accumulation is reversed. In this case, if density is also True, then the histogram is normalized such that the first bin equals 1.
Location of the bottom of each bin, ie. bins are drawn from bottom to bottom + hist(x, bins) If a scalar, the bottom of each bin is shifted by the same amount. If an array, each bin is shifted independently and the length of bottom must match the number of bins. If None, defaults to 0.
The type of histogram to draw.
The horizontal alignment of the histogram bars.
If 'horizontal', barh will be used for bar-type histograms and the bottom kwarg will be the left edges.
The relative width of the bars as a fraction of the bin width. If None, automatically compute the width.
Ignored if histtype is 'step' or 'stepfilled'.
If True, the histogram axis will be set to a log scale.
Color or sequence of colors, one per dataset. Default (None) uses the standard line color sequence.
String, or sequence of strings to match multiple datasets. Bar charts yield multiple patches per dataset, but only the first gets the label, so that legend will work as expected.
If True, multiple data are stacked on top of each other If False multiple data are arranged side by side if histtype is 'bar' or on top of each other if histtype is 'step'
The values of the histogram bins. See density and weights for a description of the possible semantics. If input x is an array, then this is an array of length nbins. If input is a sequence of arrays [data1, data2, ...], then this is a list of arrays with the values of the histograms for each of the arrays in the same order. The dtype of the array n (or of its element arrays) will always be float even if no weighting or normalization is used.
The edges of the bins. Length nbins + 1 (nbins left edges and right edge of last bin). Always a single array even when multiple data sets are passed in.
Container of individual artists used to create the histogram or list of such containers if there are multiple input datasets.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, weights
Patch properties
See also
2D histogram with rectangular bins
2D histogram with hexagonal bins
For large numbers of bins (>1000), 'step' and 'stepfilled' can be significantly faster than 'bar' and 'barstacked'.
Scatter plot with histograms
Axes Demo
Using histograms to plot a cumulative distribution
Some features of the histogram (hist) function
The histogram (hist) function with multiple data sets
Placing text boxes
Simple axes labels
Bayesian Methods for Hackers style sheet
Scatter Histogram (Locatable Axes)
Animated histogram
Frontpage histogram example
MRI With EEG
Basic Usage
Artist tutorial
Path Tutorial
Transformations Tutorial
hist(x)


Make a 2D histogram plot.
Input values
The bin specification:
The default value is 10.
The leftmost and rightmost edges of the bins along each dimension (if not specified explicitly in the bins parameters): [[xmin,
xmax], [ymin, ymax]]. All values outside of this range will be considered outliers and not tallied in the histogram.
Normalize histogram. See the documentation for the density parameter of hist for more details.
An array of values w_i weighing each sample (x_i, y_i).
All bins that has count less than cmin or more than cmax will not be displayed (set to NaN before passing to imshow) and these count values in the return value count histogram will also be set to nan upon return.
The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.
The bin edges along the x axis.
The bin edges along the y axis.
A colors.Colormap instance. If not set, use rc settings.
A colors.Normalize instance is used to scale luminance data to [0, 1]. If not set, defaults to colors.Normalize().
Arguments passed to the Normalize instance.
The alpha blending value.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y, weights
Additional parameters are passed along to the pcolormesh method and QuadMesh constructor.
See also
1D histogram plotting
2D histogram with hexagonal bins
Histograms
Exploring normalizations
hist2d(x, y)


Plot horizontal lines at each y from xmin to xmax.
y-indexes where to plot the lines.
Respective beginning and end of each line. If scalars are provided, all lines will have same length.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
y, xmin, xmax, colors
See also
vertical lines
horizontal line across the Axes
hlines and vlines
Specifying Colors


Display data as an image, i.e., on a 2D regular raster.
The input may either be actual RGB(A) data, or 2D scalar data, which will be rendered as a pseudocolor image. For displaying a grayscale image set up the colormapping using the parameters cmap='gray', vmin=0, vmax=255.
The number of pixels used to render an image is set by the Axes size and the dpi of the figure. This can lead to aliasing artifacts when the image is resampled because the displayed image size will usually not match the size of X (see Image antialiasing). The resampling can be controlled via the interpolation parameter and/or rcParams["image.interpolation"] (default: 'antialiased').
The image data. Supported array shapes are:
The first two dimensions (M, N) define the rows and columns of the image.
Out-of-range RGB(A) values are clipped.
The Colormap instance or registered colormap name used to map scalar data to colors. This parameter is ignored for RGB(A) data.
The Normalize instance used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling mapping the lowest value to 0 and the highest to 1 is used. This parameter is ignored for RGB(A) data.
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square.
This parameter is a shortcut for explicitly calling Axes.set_aspect. See there for further details.
The interpolation method used.
Supported values are 'none', 'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'.
If interpolation is 'none', then no interpolation is performed on the Agg, ps, pdf and svg backends. Other backends will fall back to 'nearest'. Note that most SVG renderers perform interpolation at rendering and that the default interpolation method they implement may differ.
If interpolation is the default 'antialiased', then 'nearest' interpolation is used if the image is upsampled by more than a factor of three (i.e. the number of display pixels is at least three times the size of the data array). If the upsampling rate is smaller than 3, or the image is downsampled, then 'hanning' interpolation is used to act as an anti-aliasing filter, unless the image happens to be upsampled by exactly a factor of two or one.
See Interpolations for imshow for an overview of the supported interpolation methods, and Image antialiasing for a discussion of image antialiasing.
Some interpolation methods require an additional radius parameter, which can be set by filterrad. Additionally, the antigrain image resize filter is controlled by the parameter filternorm.
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).
The alpha blending value, between 0 (transparent) and 1 (opaque). If alpha is an array, the alpha blending values are applied pixel by pixel, and alpha must have the same shape as X.
When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when norm is given. When using RGB(A) data, parameters vmin/vmax are ignored.
Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. The convention (the default) 'upper' is typically used for matrices and images.
Note that the vertical axis points upward for 'lower' but downward for 'upper'.
See the origin and extent in imshow tutorial for examples and a more detailed description.
The bounding box in data coordinates that the image will fill. The image is stretched individually along x and y to fill the box.
The default extent is determined by the following conditions. Pixels have unit size in data coordinates. Their centers are on integer coordinates, and their center coordinates range from 0 to columns-1 horizontally and from 0 to rows-1 vertically.
Note that the direction of the vertical axis and thus the default values for top and bottom depend on origin:
See the origin and extent in imshow tutorial for examples and a more detailed description.
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.
Set the url of the created AxesImage. See Artist.set_url.
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
These parameters are passed on to the constructor of the AxesImage artist.
See also
Plot a matrix or an array as an image.
Unless extent is used, pixel centers will be located at integer coordinates. In other words: the origin will coincide with the center of pixel (0, 0).
There are two common representations for RGB images with an alpha channel:
imshow expects RGB images adopting the straight (unassociated) alpha representation.
Bar chart with gradients
Barcode
Contour Demo
Creating annotated heatmaps
Image antialiasing
Clipping images with patches
Image Demo
Image Masked
Blend transparency with color in 2D images
Modifying the coordinate formatter
Interpolations for imshow
Pcolor Demo
Streamplot
Axes box aspect
Zoom region inset axes
Using a text as a Path
Colorbar
Creating a colormap from a list of colors
Anchored Direction Arrow
Axes Grid2
HBoxDivider demo
Adding a colorbar to inset axes
Colorbar with AxesDivider
Controlling the position and size of colorbars with Inset Axes
Inset Locator Demo2
Simple ImageGrid
Simple ImageGrid 2
Simple Colorbar
Shaded & power normalized rendering
pyplot animation
Animated image using a precomputed list of images
Image Slices Viewer
Viewlims
Patheffect Demo
MRI
MRI With EEG
Topographic hillshading
Dropped spines
Colorbar Tick Labelling
Interactive Adjustment of Colormap Range
Artist tutorial
Tight Layout guide
Choosing Colormaps in Matplotlib
imshow(Z)


Return whether the given event (in display coords) is in the Axes.


Add an inset indicator to the Axes. This is a rectangle on the plot at the position indicated by bounds that optionally has lines that connect the rectangle to an inset Axes (Axes.inset_axes).
Lower-left corner of rectangle to be marked, and its width and height.
An optional inset Axes to draw connecting lines to. Two lines are drawn connecting the indicator box to the inset Axes on corners chosen so as to not overlap with the indicator box.
Transform for the rectangle coordinates. Defaults to ax.transAxes, i.e. the units of rect are in Axes-relative coordinates.
Facecolor of the rectangle.
Color of the rectangle and color of the connecting lines.
Transparency of the rectangle and connector lines.
Drawing order of the rectangle and connector lines. The default, 4.99, is just below the default level of inset Axes.
Other keyword arguments are passed on to the Rectangle patch:
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
angle
unknown
animated
bool
antialiased or aa
bool or None
bounds
(left, bottom, width, height)
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color
color
edgecolor or ec
color or None
facecolor or fc
color or None
figure
Figure
fill
bool
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
height
unknown
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float or None
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
transform
Transform
url
str
visible
bool
width
unknown
x
unknown
xy
(float, float)
y
unknown
zorder
float
The indicator frame.
The four connector lines connecting to (lower_left, upper_left, lower_right upper_right) corners of inset_ax. Two lines are set with visibility to False, but the user can set the visibility to True if the automatic choice is not deemed correct.
Warning
This method is experimental as of 3.0, and the API may change.


Add an inset indicator rectangle to the Axes based on the axis limits for an inset_ax and draw connectors between inset_ax and the rectangle.
Inset Axes to draw connecting lines to. Two lines are drawn connecting the indicator box to the inset Axes on corners chosen so as to not overlap with the indicator box.
Other keyword arguments are passed on to Axes.indicate_inset
Rectangle artist.
Each of four connector lines coming from the rectangle drawn on this axis, in the order lower left, upper left, lower right, upper right. Two are set with visibility to False, but the user can set the visibility to True if the automatic choice is not deemed correct.
Warning
This method is experimental as of 3.0, and the API may change.
Zoom region inset axes


Add a child inset Axes to this existing Axes.
Lower-left corner of inset Axes, and its width and height.
Defaults to ax.transAxes, i.e. the units of rect are in Axes-relative coordinates.
Defaults to 5 (same as Axes.legend). Adjust higher or lower to change whether it is above or below data plotted on the parent Axes.
Other keyword arguments are passed on to the child Axes.
The created Axes instance.
Warning
This method is experimental as of 3.0, and the API may change.
This example makes two inset Axes, the first is in Axes-relative coordinates, and the second in data-coordinates:
Placing Colorbars
Zoom region inset axes


Invert the y-axis.
See also
Bar Label Demo
Horizontal bar chart
Marker reference


Place a legend on the Axes.
Call signatures:
The call signatures correspond to the following different ways to use this method:
1. Automatic detection of elements to be shown in the legend
The elements to be added to the legend are automatically determined, when you do not pass in any extra arguments.
In this case, the labels are taken from the artist. You can specify them either at artist creation or by calling the set_label() method on the artist:
or:
Specific lines can be excluded from the automatic legend element selection by defining a label starting with an underscore. This is default for all artists, so calling Axes.legend without any arguments and without setting the labels manually will result in no legend being drawn.
2. Explicitly listing the artists and labels in the legend
For full control of which artists have a legend entry, it is possible to pass an iterable of legend artists followed by an iterable of legend labels respectively:
3. Explicitly listing the artists in the legend
This is similar to 2, but the labels are taken from the artists' label properties. Example:
4. Labeling existing plot elements
Discouraged
This call signature is discouraged, because the relation between plot elements and labels is only implicit by their order and can easily be mixed up.
To make a legend for all artists on an Axes, call this function with an iterable of strings, one for each legend item. For example:
A list of Artists (lines, patches) to be added to the legend. Use this together with labels, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient.
The length of handles and labels should be the same in this case. If they are not, they are truncated to the smaller length.
A list of labels to show next to the artists. Use this together with handles, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient.
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.
See also
Some artists are not supported by this function. See Legend guide for details.
(Source code, png, pdf)
Bar Label Demo
Stacked bar chart
Grouped bar chart with labels
Plotting categorical variables
Fill Between and Alpha
Hat graph
Customizing dashed line styles
Lines with a ticked patheffect
prop_cycle property markevery in rcParams
Scatter plots with a legend
Stackplots and streamgraphs
Stairs Demo
Contourf Hatching
Tricontour Demo
Secondary Axis
Plot a confidence ellipse of a two-dimensional dataset
Using histograms to plot a cumulative distribution
The histogram (hist) function with multiple data sets
Bar of pie
Labeling a pie and a donut
Polar Legend
Composing Custom Legends
Legend using pre-defined labels
Legend Demo
Mathtext
Rendering math equations using TeX
Parasite Axes demo
Parasite axis demo
Anatomy of a figure
Legend Picking
Patheffect Demo
TickedStroke patheffect
Plot 2D data on 3D plot
Parametric Curve
Multiple Yaxis With Spines
Group barchart with units
Simple Legend01
Simple Legend02
Basic Usage
Legend guide
Constrained Layout Guide
Tight Layout guide
Specifying Colors


Control behavior of major tick locators.
Because the locator is involved in autoscaling, autoscale_view is called automatically after the parameters are changed.
The axis on which to operate.
Parameter passed to autoscale_view. Default is None, for no change.
Remaining keyword arguments are passed to directly to the set_params() method of the locator. Supported keywords depend on the type of the locator. See for example set_params for the ticker.MaxNLocator used by default for linear axes.
When plotting small subplots, one might want to reduce the maximum number of ticks and use tight bounds, for example:
Contourf Demo
Constrained Layout Guide
Tight Layout guide


Make a plot with log scaling on both the x and y axis.
Call signatures:
This is just a thin wrapper around plot which additionally changes both the x-axis and the y-axis to log scaling. All of the concepts and parameters of plot can be used here as well.
The additional parameters base, subs and nonpositive control the x/y-axis properties. They are just forwarded to Axes.set_xscale and Axes.set_yscale. To use different properties on the x-axis and the y-axis, use e.g. ax.set_xscale("log", base=10); ax.set_yscale("log", base=2).
Base of the logarithm.
The location of the minor ticks. If None, reasonable locations are automatically chosen depending on the number of decades in the plot. See Axes.set_xscale/Axes.set_yscale for details.
Non-positive values can be masked as invalid, or clipped to a very small positive number.
All parameters supported by plot.
Objects representing the plotted data.
Secondary Axis
Log Demo


Plot the magnitude spectrum.
Compute the magnitude spectrum of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.
Array or sequence containing the data.
The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit.
A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.
Which sides of the spectrum to return. 'default' is one-sided for real data and two-sided for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.
The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).
The scaling of the values in the spec. 'linear' is no scaling. 'dB' returns the values in dB scale, i.e., the dB amplitude (20 * log10). 'default' is 'linear'.
The center frequency of x, which offsets the x extents of the plot to reflect the frequency range used when a signal is acquired and then filtered and downsampled to baseband.
The values for the magnitude spectrum before scaling (real valued).
The frequencies corresponding to the elements in spectrum.
The line created by this function.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x
Keyword arguments control the Line2D properties:
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
antialiased or aa
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
dash_capstyle
CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
dashes
sequence of floats (on/off ink in points) or (None, None)
data
(2, N) array or two 1D arrays
drawstyle or ds
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure
Figure
fillstyle
{'full', 'left', 'right', 'bottom', 'top', 'none'}
gid
str
in_layout
bool
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float
marker
marker style string, Path or MarkerStyle
markeredgecolor or mec
color
markeredgewidth or mew
float
markerfacecolor or mfc
color
markerfacecoloralt or mfcalt
color
markersize or ms
float
markevery
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects
AbstractPathEffect
picker
float or callable[[Artist, Event], tuple[bool, dict]]
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
solid_capstyle
CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
transform
unknown
url
str
visible
bool
xdata
1D array
ydata
1D array
zorder
float
See also
Plots the power spectral density.
Plots the angles of the corresponding frequencies.
Plots the phase (unwrapped angle) of the corresponding frequencies.
Can plot the magnitude spectrum of segments within the signal in a colormap.


Set or retrieve autoscaling margins.
The padding added to each limit of the Axes is the margin times the data interval. All input parameters must be floats within the range [0, 1]. Passing both positional and keyword arguments is invalid and will raise a TypeError. If no arguments (positional or otherwise) are provided, the current margins will remain in place and simply be returned.
Specifying any margin changes only the autoscaling; for example, if xmargin is not None, then xmargin times the X data interval will be added to each end of that interval before it is used in autoscaling.
If a single positional argument is provided, it specifies both margins of the x-axis and y-axis limits. If two positional arguments are provided, they will be interpreted as xmargin, ymargin. If setting the margin on a single axis is desired, use the keyword arguments described below.
Specific margin values for the x-axis and y-axis, respectively. These cannot be used with positional arguments, but can be used individually to alter on e.g., only the y-axis.
The tight parameter is passed to autoscale_view(), which is executed after a margin is changed; the default here is True, on the assumption that when margins are specified, no additional padding to match tick marks is usually desired. Set tight to None will preserve the previous setting.
If a previously used Axes method such as pcolor() has set use_sticky_edges to True, only the limits not set by the "sticky artists" will be modified. To force all of the margins to be set, set use_sticky_edges to False before calling margins().
Marker reference
Creating a timeline with lines, dates, and text
Trigradient Demo
Controlling view limits using margins and sticky_edges
Scale invariant angle label
ggplot style sheet
Autoscaling


Plot the values of a 2D matrix or array as color-coded image.
The matrix will be shown the way it would be printed, with the first row at the top. Row and column numbering is zero-based.
The matrix to be displayed.
See also
More general function to plot data on a 2D regular raster.
This is just a convenience function wrapping imshow to set useful defaults for displaying a matrix. In particular:


Display minor ticks on the Axes.
Displaying minor ticks may reduce performance; you may turn them off using minorticks_off() if drawing speed is a problem.
MRI With EEG


If this property is set to True, the artist will be queried for custom context information when the mouse cursor moves over it.
See also get_cursor_data(), ToolCursorPosition and NavigationToolbar2.


Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also


Create a pseudocolor plot with a non-regular rectangular grid.
Call signature:
X and Y can be used to specify the corners of the quadrilaterals.
Hint
pcolor() can be very slow for large arrays. In most cases you should use the similar but much faster pcolormesh instead. See Differences between pcolor() and pcolormesh() for a discussion of the differences.
The color-mapped values.
The coordinates of the corners of quadrilaterals of a pcolormesh:
Note that the column index corresponds to the x-coordinate, and the row index corresponds to y. For details, see the Notes section below.
If shading='flat' the dimensions of X and Y should be one greater than those of C, and the quadrilateral is colored due to the value at C[i, j]. If X, Y and C have equal dimensions, a warning will be raised and the last row and column of C will be ignored.
If shading='nearest', the dimensions of X and Y should be the same as those of C (if not, a ValueError will be raised). The color C[i, j] will be centered on (X[i, j], Y[i, j]).
If X and/or Y are 1-D arrays or column vectors they will be expanded as needed into the appropriate 2D arrays, making a rectangular grid.
The fill style for the quadrilateral. Possible values:
See pcolormesh grids and shading for more description.
A Colormap instance or registered colormap name. The colormap maps the C values to colors.
The Normalize instance scales the data values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
The colorbar range. If None, suitable min/max values are automatically chosen by the Normalize instance (defaults to the respective min/max values of C in case of the default linear scaling). It is an error to use vmin/vmax when norm is given.
The color of the edges. Defaults to 'none'. Possible values:
The singular form edgecolor works as an alias.
The alpha blending value of the face color, between 0 (transparent) and 1 (opaque). Note: The edgecolor is currently not affected by this.
Whether to snap the mesh to pixel boundaries.
The default antialiaseds is False if the default edgecolors="none" is used. This eliminates artificial lines at patch boundaries, and works regardless of the value of alpha. If edgecolors is not "none", then the default antialiaseds is taken from rcParams["patch.antialiased"] (default: True). Stroking the edges may be preferred if alpha is 1, but will cause artifacts otherwise.
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
Additionally, the following arguments are allowed. They are passed along to the PolyCollection constructor:
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
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
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
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
See also
for an explanation of the differences between pcolor and pcolormesh.
If X and Y are each equidistant, imshow can be a faster alternative.
Masked arrays
X, Y and C may be masked arrays. If either C[i, j], or one of the vertices surrounding C[i, j] (X or Y at [i, j], [i+1, j], [i, j+1], [i+1, j+1]) is masked, nothing is plotted.
Grid orientation
The grid orientation follows the standard matrix convention: An array C with shape (nrows, ncolumns) is plotted with the column number as X and the row number as Y.
Pcolor Demo
Controlling view limits using margins and sticky_edges


Create a pseudocolor plot with a non-regular rectangular grid.
Call signature:
This method is similar to pcolor and pcolormesh. It's designed to provide the fastest pcolor-type plotting with the Agg backend. To achieve this, it uses different algorithms internally depending on the complexity of the input grid (regular rectangular, non-regular rectangular or arbitrary quadrilateral).
Warning
This method is experimental. Compared to pcolor or pcolormesh it has some limitations:
The image data. Supported array shapes are:
The first two dimensions (M, N) define the rows and columns of the image.
This parameter can only be passed positionally.
X and Y are used to specify the coordinates of the quadrilaterals. There are different ways to do this:
Use tuples X=(xmin, xmax) and Y=(ymin, ymax) to define a uniform rectangular grid.
The tuples define the outer edges of the grid. All individual quadrilaterals will be of the same size. This is the fastest version.
Use 1D arrays X, Y to specify a non-uniform rectangular grid.
In this case X and Y have to be monotonic 1D arrays of length N+1 and M+1, specifying the x and y boundaries of the cells.
The speed is intermediate. Note: The grid is checked, and if found to be uniform the fast version is used.
Use 2D arrays X, Y if you need an arbitrary quadrilateral grid (i.e. if the quadrilaterals are not rectangular).
In this case X and Y are 2D arrays with shape (M + 1, N + 1), specifying the x and y coordinates of the corners of the colored quadrilaterals.
This is the most general, but the slowest to render. It may produce faster and more compact output using ps, pdf, and svg backends, however.
These arguments can only be passed positionally.
A Colormap instance or registered colormap name. The colormap maps the C values to colors.
The Normalize instance scales the data values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
The colorbar range. If None, suitable min/max values are automatically chosen by the Normalize instance (defaults to the respective min/max values of C in case of the default linear scaling). It is an error to use vmin/vmax when norm is given.
The alpha blending value, between 0 (transparent) and 1 (opaque).
Whether to snap the mesh to pixel boundaries.
The return type depends on the type of grid:
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
Supported additional parameters depend on the type of grid. See return types of image for further description.
Pcolor Demo


Create a pseudocolor plot with a non-regular rectangular grid.
Call signature:
X and Y can be used to specify the corners of the quadrilaterals.
Hint
pcolormesh is similar to pcolor. It is much faster and preferred in most cases. For a detailed discussion on the differences see Differences between pcolor() and pcolormesh().
The color-mapped values.
The coordinates of the corners of quadrilaterals of a pcolormesh:
Note that the column index corresponds to the x-coordinate, and the row index corresponds to y. For details, see the Notes section below.
If shading='flat' the dimensions of X and Y should be one greater than those of C, and the quadrilateral is colored due to the value at C[i, j]. If X, Y and C have equal dimensions, a warning will be raised and the last row and column of C will be ignored.
If shading='nearest' or 'gouraud', the dimensions of X and Y should be the same as those of C (if not, a ValueError will be raised). For 'nearest' the color C[i, j] is centered on (X[i, j], Y[i, j]). For 'gouraud', a smooth interpolation is caried out between the quadrilateral corners.
If X and/or Y are 1-D arrays or column vectors they will be expanded as needed into the appropriate 2D arrays, making a rectangular grid.
A Colormap instance or registered colormap name. The colormap maps the C values to colors.
The Normalize instance scales the data values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
The colorbar range. If None, suitable min/max values are automatically chosen by the Normalize instance (defaults to the respective min/max values of C in case of the default linear scaling). It is an error to use vmin/vmax when norm is given.
The color of the edges. Defaults to 'none'. Possible values:
The singular form edgecolor works as an alias.
The alpha blending value, between 0 (transparent) and 1 (opaque).
The fill style for the quadrilateral; defaults to 'flat' or rcParams["pcolor.shading"] (default: 'auto'). Possible values:
See pcolormesh grids and shading for more description.
Whether to snap the mesh to pixel boundaries.
Rasterize the pcolormesh when drawing vector graphics. This can speed up rendering and produce smaller files for large data sets. See also Rasterization for vector graphics.
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
Additionally, the following arguments are allowed. They are passed along to the QuadMesh constructor:
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
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
(M, N) array-like or M*N array-like
capstyle
CapStyle or {'butt', 'projecting', 'round'}
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
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
visible
bool
zorder
float
See also
An alternative implementation with slightly different features. For a detailed discussion on the differences see Differences between pcolor() and pcolormesh().
If X and Y are each equidistant, imshow can be a faster alternative.
Masked arrays
C may be a masked array. If C[i, j] is masked, the corresponding quadrilateral will be transparent. Masking of X and Y is not supported. Use pcolor if you need this functionality.
Grid orientation
The grid orientation follows the standard matrix convention: An array C with shape (nrows, ncolumns) is plotted with the column number as X and the row number as Y.
Differences between pcolor() and pcolormesh()
Both methods are used to create a pseudocolor plot of a 2D array using quadrilaterals.
The main difference lies in the created object and internal data handling: While pcolor returns a PolyCollection, pcolormesh returns a QuadMesh. The latter is more specialized for the given purpose and thus is faster. It should almost always be preferred.
There is also a slight difference in the handling of masked arrays. Both pcolor and pcolormesh support masked arrays for C. However, only pcolor supports masked arrays for X and Y. The reason lies in the internal handling of the masked values. pcolor leaves out the respective polygons from the PolyCollection. pcolormesh sets the facecolor of the masked elements to transparent. You can see the difference when using edgecolors. While all edges are drawn irrespective of masking in a QuadMesh, the edge between two adjacent masked quadrilaterals in pcolor is not drawn as the corresponding polygons do not exist in the PolyCollection.
Another difference is the support of Gouraud shading in pcolormesh, which is not available with pcolor.
Pcolor Demo
pcolormesh grids and shading
pcolormesh
Placing Colorbars
Figure subfigures
Rasterization for vector graphics
Constrained Layout Guide
Colormap Normalization
pcolormesh(X, Y, Z)


Plot the phase spectrum.
Compute the phase spectrum (unwrapped angle spectrum) of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.
Array or sequence containing the data
The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit.
A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.
Which sides of the spectrum to return. 'default' is one-sided for real data and two-sided for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.
The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).
The center frequency of x, which offsets the x extents of the plot to reflect the frequency range used when a signal is acquired and then filtered and downsampled to baseband.
The values for the phase spectrum in radians (real valued).
The frequencies corresponding to the elements in spectrum.
The line created by this function.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x
Keyword arguments control the Line2D properties:
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
antialiased or aa
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
dash_capstyle
CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
dashes
sequence of floats (on/off ink in points) or (None, None)
data
(2, N) array or two 1D arrays
drawstyle or ds
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure
Figure
fillstyle
{'full', 'left', 'right', 'bottom', 'top', 'none'}
gid
str
in_layout
bool
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float
marker
marker style string, Path or MarkerStyle
markeredgecolor or mec
color
markeredgewidth or mew
float
markerfacecolor or mfc
color
markerfacecoloralt or mfcalt
color
markersize or ms
float
markevery
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects
AbstractPathEffect
picker
float or callable[[Artist, Event], tuple[bool, dict]]
pickradius
float
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
solid_capstyle
CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
transform
unknown
url
str
visible
bool
xdata
1D array
ydata
1D array
zorder
float
See also
Plots the magnitudes of the corresponding frequencies.
Plots the wrapped version of this function.
Can plot the phase spectrum of segments within the signal in a colormap.


Plot a pie chart.
Make a pie chart of array x. The fractional area of each wedge is given by x/sum(x). If sum(x) < 1, then the values of x give the fractional area directly and the array will not be normalized. The resulting pie will have an empty wedge of size 1 - sum(x).
The wedges are plotted counterclockwise, by default starting from the x-axis.
The wedge sizes.
If not None, is a len(x) array which specifies the fraction of the radius with which to offset each wedge.
A sequence of strings providing the labels for each wedge
A sequence of colors through which the pie chart will cycle. If None, will use the colors in the currently active cycle.
If not None, is a string or function used to label the wedges with their numeric value. The label will be placed inside the wedge. If it is a format string, the label will be fmt % pct. If it is a function, it will be called.
The ratio between the center of each pie slice and the start of the text generated by autopct. Ignored if autopct is None.
Draw a shadow beneath the pie.
When True, always make a full pie by normalizing x so that sum(x) == 1. False makes a partial pie if sum(x) <= 1 and raises a ValueError for sum(x) > 1.
The radial distance at which the pie labels are drawn. If set to None, label are not drawn, but are stored for use in legend()
The angle by which the start of the pie is rotated, counterclockwise from the x-axis.
The radius of the pie.
Specify fractions direction, clockwise or counterclockwise.
Dict of arguments passed to the wedge objects making the pie. For example, you can pass in wedgeprops = {'linewidth': 3} to set the width of the wedge border lines equal to 3. For more details, look at the doc/arguments of the wedge object. By default clip_on=False.
Dict of arguments to pass to the text objects.
The coordinates of the center of the chart.
Plot Axes frame with the chart if true.
Rotate each label to the angle of the corresponding slice if true.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, explode, labels, colors
A sequence of matplotlib.patches.Wedge instances
A list of the label Text instances.
A list of Text instances for the numeric labels. This will only be returned if the parameter autopct is not None.
The pie chart will probably look best if the figure and Axes are square, or the Axes aspect is equal. This method sets the aspect ratio of the axis to "equal". The Axes aspect ratio can be controlled with Axes.set_aspect.
Basic pie chart
Bar of pie
Nested pie charts
Labeling a pie and a donut
SVG Filter Pie
pie(x)