matplotlib.axes.Axes.contains   Axes.contains(mouseevent)[source]

Test whether the artist contains the mouse event.  Parameters

mouseeventmatplotlib.backend_bases.MouseEvent

  Returns

containsbool

Whether any values are within the radius.
detailsdict

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.


matplotlib.axes.Axes.contains_point   Axes.contains_point(point)[source]

Return whether point (pair of pixel coordinates) is inside the axes patch.


matplotlib.axes.Axes.contour   Axes.contour(*args, data=None, **kwargs)[source]

Plot contour lines. Call signature: contour([X, Y,] Z, [levels], **kwargs)
 contour and contourf draw contour lines and filled contours, respectively. Except as noted, function signatures and return values are the same for both versions.  Parameters

X, Yarray-like, optional

The coordinates of the values in Z. X and Y must both be 2D with the same shape as Z (e.g. created via numpy.meshgrid), or they must both be 1-D such that len(X) == N is the number of columns in Z and len(Y) == M is the number of rows in Z. X and Y must both be ordered monotonically. If not given, they are assumed to be integer indices, i.e. X = range(N), Y = range(M).
Z(M, N) array-like

The height values over which the contour is drawn.
levelsint or array-like, optional

Determines the number and positions of the contour lines / regions. If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between vmin and vmax. If array-like, draw contour lines at the specified levels. The values must be in increasing order.    Returns
 QuadContourSet
  Other Parameters

corner_maskbool, default: rcParams["contour.corner_mask"] (default: True)

Enable/disable corner masking, which only has an effect if Z is a masked array. If False, any quad touching a masked point is masked out. If True, only the triangular corners of quads nearest those points are always masked out, other triangular corners comprising three unmasked points are contoured as usual.
colorscolor string or sequence of colors, optional

The colors of the levels, i.e. the lines for contour and the areas for contourf. The sequence is cycled for the levels in ascending order. If the sequence is shorter than the number of levels, it's repeated. As a shortcut, single color strings may be used in place of one-element lists, i.e. 'red' instead of ['red'] to color all levels with the same color. This shortcut does only work for color strings, not for other ways of specifying colors. By default (value None), the colormap specified by cmap will be used.
alphafloat, default: 1

The alpha blending value, between 0 (transparent) and 1 (opaque).
cmapstr or Colormap, default: rcParams["image.cmap"] (default: 'viridis')

A Colormap instance or registered colormap name. The colormap maps the level values to colors. If both colors and cmap are given, an error is raised.
normNormalize, optional

If a colormap is used, the Normalize instance scales the level values to the canonical colormap range [0, 1] for mapping to colors. If not given, the default linear scaling is used.
vmin, vmaxfloat, optional

If not None, either or both of these values will be supplied to the Normalize instance, overriding the default color scaling based on levels.
origin{None, 'upper', 'lower', 'image'}, default: None

Determines the orientation and exact position of Z by specifying the position of Z[0, 0]. This is only relevant, if X, Y are not given.
None: Z[0, 0] is at X=0, Y=0 in the lower left corner. 'lower': Z[0, 0] is at X=0.5, Y=0.5 in the lower left corner. 'upper': Z[0, 0] is at X=N+0.5, Y=0.5 in the upper left corner. 'image': Use the value from rcParams["image.origin"] (default: 'upper').
extent(x0, x1, y0, y1), optional

If origin is not None, then extent is interpreted as in imshow: it gives the outer pixel boundaries. In this case, the position of Z[0, 0] is the center of the pixel, not a corner. If origin is None, then (x0, y0) is the position of Z[0, 0], and (x1, y1) is the position of Z[-1, -1]. This argument is ignored if X and Y are specified in the call to contour.
locatorticker.Locator subclass, optional

The locator is used to determine the contour levels if they are not given explicitly via levels. Defaults to MaxNLocator.
extend{'neither', 'both', 'min', 'max'}, default: 'neither'

Determines the contourf-coloring of values that are outside the levels range. If 'neither', values outside the levels range are not colored. If 'min', 'max' or 'both', color the values below, above or below and above the levels range. Values below min(levels) and above max(levels) are mapped to the under/over values of the Colormap. Note that most colormaps do not have dedicated colors for these by default, so that the over and under values are the edge values of the colormap. You may want to set these values explicitly using Colormap.set_under and Colormap.set_over.  Note An existing QuadContourSet does not get notified if properties of its colormap are changed. Therefore, an explicit call QuadContourSet.changed() is needed after modifying the colormap. The explicit call can be left out, if a colorbar is assigned to the QuadContourSet because it internally calls QuadContourSet.changed().  Example: x = np.arange(1, 10)
y = x.reshape(-1, 1)
h = x * y

cs = plt.contourf(h, levels=[10, 30, 50],
    colors=['#808080', '#A0A0A0', '#C0C0C0'], extend='both')
cs.cmap.set_over('red')
cs.cmap.set_under('blue')
cs.changed()

xunits, yunitsregistered units, optional

Override axis units by specifying an instance of a matplotlib.units.ConversionInterface.
antialiasedbool, optional

Enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams["lines.antialiased"] (default: True).
nchunkint >= 0, optional

If 0, no subdivision of the domain. Specify a positive integer to divide the domain into subdomains of nchunk by nchunk quads. Chunking reduces the maximum length of polygons generated by the contouring algorithm which reduces the rendering workload passed on to the backend and also requires slightly less RAM. It can however introduce rendering artifacts at chunk boundaries depending on the backend, the antialiased flag and value of alpha.
linewidthsfloat or array-like, default: rcParams["contour.linewidth"] (default: None)

Only applies to contour. The line width of the contour lines. If a number, all levels will be plotted with this linewidth. If a sequence, the levels in ascending order will be plotted with the linewidths in the order specified. If None, this falls back to rcParams["lines.linewidth"] (default: 1.5).
linestyles{None, 'solid', 'dashed', 'dashdot', 'dotted'}, optional

Only applies to contour. If linestyles is None, the default is 'solid' unless the lines are monochrome. In that case, negative contours will take their linestyle from rcParams["contour.negative_linestyle"] (default: 'dashed') setting. linestyles can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary.
hatcheslist[str], optional

Only applies to contourf. A list of cross hatch patterns to use on the filled areas. If None, no hatching will be added to the contour. Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
dataindexable object, optional

If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).     Notes
contourf differs from the MATLAB version in that it does not draw the polygon edges. To draw edges, add line contours with calls to contour.
contourf fills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is: z1 < Z <= z2
 except for the lowest interval, which is closed on both sides (i.e. it includes the lowest value).
contour and contourf use a marching squares algorithm to compute contour locations. More information can be found in the source src/_contour.h.
  Examples using matplotlib.axes.Axes.contour

   Contour Corner Mask

   Contour Demo

   Contour Label Demo

   Contourf Demo

   Contourf Hatching

   Contouring the solution space of optimizations

   Blend transparency with color in 2D images

   Contour plot of irregularly spaced data

   Patheffect Demo

   TickedStroke patheffect

   Demonstrates plotting contour (level) curves in 3D

   Demonstrates plotting contour (level) curves in 3D using the extend3d option

   Projecting contour profiles onto a graph

   contour(X, Y, Z)


matplotlib.axes.Axes.contourf   Axes.contourf(*args, data=None, **kwargs)[source]

Plot filled contours. Call signature: contourf([X, Y,] Z, [levels], **kwargs)
 contour and contourf draw contour lines and filled contours, respectively. Except as noted, function signatures and return values are the same for both versions.  Parameters

X, Yarray-like, optional

The coordinates of the values in Z. X and Y must both be 2D with the same shape as Z (e.g. created via numpy.meshgrid), or they must both be 1-D such that len(X) == N is the number of columns in Z and len(Y) == M is the number of rows in Z. X and Y must both be ordered monotonically. If not given, they are assumed to be integer indices, i.e. X = range(N), Y = range(M).
Z(M, N) array-like

The height values over which the contour is drawn.
levelsint or array-like, optional

Determines the number and positions of the contour lines / regions. If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between vmin and vmax. If array-like, draw contour lines at the specified levels. The values must be in increasing order.    Returns
 QuadContourSet
  Other Parameters

corner_maskbool, default: rcParams["contour.corner_mask"] (default: True)

Enable/disable corner masking, which only has an effect if Z is a masked array. If False, any quad touching a masked point is masked out. If True, only the triangular corners of quads nearest those points are always masked out, other triangular corners comprising three unmasked points are contoured as usual.
colorscolor string or sequence of colors, optional

The colors of the levels, i.e. the lines for contour and the areas for contourf. The sequence is cycled for the levels in ascending order. If the sequence is shorter than the number of levels, it's repeated. As a shortcut, single color strings may be used in place of one-element lists, i.e. 'red' instead of ['red'] to color all levels with the same color. This shortcut does only work for color strings, not for other ways of specifying colors. By default (value None), the colormap specified by cmap will be used.
alphafloat, default: 1

The alpha blending value, between 0 (transparent) and 1 (opaque).
cmapstr or Colormap, default: rcParams["image.cmap"] (default: 'viridis')

A Colormap instance or registered colormap name. The colormap maps the level values to colors. If both colors and cmap are given, an error is raised.
normNormalize, optional

If a colormap is used, the Normalize instance scales the level values to the canonical colormap range [0, 1] for mapping to colors. If not given, the default linear scaling is used.
vmin, vmaxfloat, optional

If not None, either or both of these values will be supplied to the Normalize instance, overriding the default color scaling based on levels.
origin{None, 'upper', 'lower', 'image'}, default: None

Determines the orientation and exact position of Z by specifying the position of Z[0, 0]. This is only relevant, if X, Y are not given.
None: Z[0, 0] is at X=0, Y=0 in the lower left corner. 'lower': Z[0, 0] is at X=0.5, Y=0.5 in the lower left corner. 'upper': Z[0, 0] is at X=N+0.5, Y=0.5 in the upper left corner. 'image': Use the value from rcParams["image.origin"] (default: 'upper').
extent(x0, x1, y0, y1), optional

If origin is not None, then extent is interpreted as in imshow: it gives the outer pixel boundaries. In this case, the position of Z[0, 0] is the center of the pixel, not a corner. If origin is None, then (x0, y0) is the position of Z[0, 0], and (x1, y1) is the position of Z[-1, -1]. This argument is ignored if X and Y are specified in the call to contour.
locatorticker.Locator subclass, optional

The locator is used to determine the contour levels if they are not given explicitly via levels. Defaults to MaxNLocator.
extend{'neither', 'both', 'min', 'max'}, default: 'neither'

Determines the contourf-coloring of values that are outside the levels range. If 'neither', values outside the levels range are not colored. If 'min', 'max' or 'both', color the values below, above or below and above the levels range. Values below min(levels) and above max(levels) are mapped to the under/over values of the Colormap. Note that most colormaps do not have dedicated colors for these by default, so that the over and under values are the edge values of the colormap. You may want to set these values explicitly using Colormap.set_under and Colormap.set_over.  Note An existing QuadContourSet does not get notified if properties of its colormap are changed. Therefore, an explicit call QuadContourSet.changed() is needed after modifying the colormap. The explicit call can be left out, if a colorbar is assigned to the QuadContourSet because it internally calls QuadContourSet.changed().  Example: x = np.arange(1, 10)
y = x.reshape(-1, 1)
h = x * y

cs = plt.contourf(h, levels=[10, 30, 50],
    colors=['#808080', '#A0A0A0', '#C0C0C0'], extend='both')
cs.cmap.set_over('red')
cs.cmap.set_under('blue')
cs.changed()

xunits, yunitsregistered units, optional

Override axis units by specifying an instance of a matplotlib.units.ConversionInterface.
antialiasedbool, optional

Enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams["lines.antialiased"] (default: True).
nchunkint >= 0, optional

If 0, no subdivision of the domain. Specify a positive integer to divide the domain into subdomains of nchunk by nchunk quads. Chunking reduces the maximum length of polygons generated by the contouring algorithm which reduces the rendering workload passed on to the backend and also requires slightly less RAM. It can however introduce rendering artifacts at chunk boundaries depending on the backend, the antialiased flag and value of alpha.
linewidthsfloat or array-like, default: rcParams["contour.linewidth"] (default: None)

Only applies to contour. The line width of the contour lines. If a number, all levels will be plotted with this linewidth. If a sequence, the levels in ascending order will be plotted with the linewidths in the order specified. If None, this falls back to rcParams["lines.linewidth"] (default: 1.5).
linestyles{None, 'solid', 'dashed', 'dashdot', 'dotted'}, optional

Only applies to contour. If linestyles is None, the default is 'solid' unless the lines are monochrome. In that case, negative contours will take their linestyle from rcParams["contour.negative_linestyle"] (default: 'dashed') setting. linestyles can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary.
hatcheslist[str], optional

Only applies to contourf. A list of cross hatch patterns to use on the filled areas. If None, no hatching will be added to the contour. Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
dataindexable object, optional

If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).     Notes
contourf differs from the MATLAB version in that it does not draw the polygon edges. To draw edges, add line contours with calls to contour.
contourf fills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is: z1 < Z <= z2
 except for the lowest interval, which is closed on both sides (i.e. it includes the lowest value).
contour and contourf use a marching squares algorithm to compute contour locations. More information can be found in the source src/_contour.h.
  Examples using matplotlib.axes.Axes.contourf

   Contour Corner Mask

   Contourf Demo

   Contourf Hatching

   Contourf and log color scale

   Contour plot of irregularly spaced data

   pcolormesh

   Frontpage contour example

   3D box surface plot

   Filled contours

   Projecting filled contour onto a graph

   contourf(X, Y, Z)


matplotlib.axes.Axes.convert_xunits   Axes.convert_xunits(x)[source]

Convert x using the unit type of the xaxis. If the artist is not in contained in an Axes or if the xaxis does not have units, x itself is returned.


matplotlib.axes.Axes.convert_yunits   Axes.convert_yunits(y)[source]

Convert y using the unit type of the yaxis. If the artist is not in contained in an Axes or if the yaxis does not have units, y itself is returned.


matplotlib.axes.Axes.csd   Axes.csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, return_line=None, *, data=None, **kwargs)[source]

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.  Parameters

x, y1-D arrays or sequences

Arrays or sequences containing the data.
Fsfloat, default: 2

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit.
windowcallable or ndarray, default: window_hanning

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.
sides{'default', 'onesided', 'twosided'}, optional

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.
pad_toint, optional

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
NFFTint, default: 256

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.
detrend{'none', 'mean', 'linear'} or callable, default: 'none'

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.
scale_by_freqbool, default: True

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.
noverlapint, default: 0 (no overlap)

The number of points of overlap between segments.
Fcint, default: 0

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.
return_linebool, default: False

Whether to include the line object plotted in the returned values.    Returns

Pxy1-D array

The values for the cross spectrum \(P_{xy}\) before scaling (complex valued).
freqs1-D array

The frequencies corresponding to the elements in Pxy.
lineLine2D

The line created by this function. Only returned if return_line is True.    Other Parameters

dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception): x, y  **kwargs

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  psd

is equivalent to setting y = x.    Notes For plotting, the power is plotted as \(10 \log_{10}(P_{xy})\) for decibels, though \(P_{xy}\) itself is returned. References Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)
  Examples using matplotlib.axes.Axes.csd

   CSD Demo


matplotlib.axes.Axes.drag_pan   Axes.drag_pan(button, key, x, y)[source]

Called when the mouse moves during a pan operation.  Parameters

buttonMouseButton

The pressed mouse button.
keystr or None

The pressed key, if any.
x, yfloat

The mouse coordinates in display coords.     Notes This is intended to be overridden by new projection types.


matplotlib.axes.Axes.draw   Axes.draw(renderer)[source]

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).  Parameters

rendererRendererBase subclass.

   Notes This method is overridden in the Artist subclasses.


matplotlib.axes.Axes.draw_artist   Axes.draw_artist(a)[source]

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.
  Examples using matplotlib.axes.Axes.draw_artist

   Faster rendering by using blitting


matplotlib.axes.Axes.end_pan   Axes.end_pan()[source]

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


matplotlib.axes.Axes.errorbar   Axes.errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, *, data=None, **kwargs)[source]

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.  Parameters

x, yfloat or array-like

The data positions.
xerr, yerrfloat or array-like, shape(N,) or shape(2, N), optional

The errorbar sizes:  scalar: Symmetric +/- values for all data points. shape(N,): Symmetric +/-values for each data point. shape(2, N): Separate - and + values for each bar. First row contains the lower errors, the second row contains the upper errors.
None: No errorbar.  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.
fmtstr, default: ''

The format for the data points / data lines. See plot for details. Use 'none' (case insensitive) to plot errorbars without any data markers.
ecolorcolor, default: None

The color of the errorbar lines. If None, use the color of the line connecting the markers.
elinewidthfloat, default: None

The linewidth of the errorbar lines. If None, the linewidth of the current style is used.
capsizefloat, default: rcParams["errorbar.capsize"] (default: 0.0)

The length of the error bar caps in points.
capthickfloat, default: None

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.
barsabovebool, default: False

If True, will plot the errorbars above the plot symbols. Default is below.
lolims, uplims, xlolims, xuplimsbool, default: False

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!
erroreveryint or (int, int), default: 1

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.    Returns
 ErrorbarContainer

The container contains:  plotline: Line2D instance of x, y plot markers and/or line. caplines: A tuple of Line2D instances of the error bar caps. barlinecols: A tuple of LineCollection with the horizontal and vertical error ranges.     Other Parameters

dataindexable object, optional

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  **kwargs

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: x, y, yerr = rand(3, 10)
errorbar(x, y, yerr, marker='s', mfc='red',
         mec='green', ms=20, mew=4)
 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
  Examples using matplotlib.axes.Axes.errorbar

   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)


matplotlib.axes.Axes.eventplot   Axes.eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1, linewidths=None, colors=None, linestyles='solid', *, data=None, **kwargs)[source]

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.  Parameters

positionsarray-like or list of array-like

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.
orientation{'horizontal', 'vertical'}, default: 'horizontal'

The direction of the event sequence:  'horizontal': the events are arranged horizontally. The indicator lines are vertical. 'vertical': the events are arranged vertically. The indicator lines are horizontal.
lineoffsetsfloat or array-like, default: 1

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.
linelengthsfloat or array-like, default: 1

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.
linewidthsfloat or array-like, default: rcParams["lines.linewidth"] (default: 1.5)

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.
colorscolor or list of colors, default: rcParams["lines.color"] (default: 'C0')

The color(s) of the event lines. If positions is 2D, this can be a sequence with length matching the length of positions.
linestylesstr or tuple or list of such values, default: 'solid'

Default is 'solid'. Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form: (offset, onoffseq),
 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.
dataindexable object, optional

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  **kwargs

Other keyword arguments are line collection properties. See LineCollection for a list of the valid properties.    Returns
 list of EventCollection

The EventCollection that were added.     Notes 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. Examples (Source code, png, pdf)
  Examples using matplotlib.axes.Axes.eventplot

   eventplot(D)


matplotlib.axes.Axes.fill   Axes.fill(*args, data=None, **kwargs)[source]

Plot filled polygons.  Parameters

*argssequence of x, y, [color]

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: ax.fill(x, y)                    # a polygon with default color
ax.fill(x, y, "b")               # a blue polygon
ax.fill(x, y, x2, y2)            # two polygons
ax.fill(x, y, "b", x2, y2, "r")  # a blue and a red polygon

dataindexable object, optional

An object with labelled data. If given, provide the label names to plot in x and y, e.g.: ax.fill("time", "signal",
        data={"time": [0, 1, 2], "signal": [0, 1, 0]})
    Returns
 list of Polygon

  Other Parameters

**kwargsPolygon properties

   Notes Use fill_between() if you would like to fill the region between two curves.
  Examples using matplotlib.axes.Axes.fill

   Filled polygon

   Radar chart (aka spider or star chart)

   Ellipse With Units


matplotlib.axes.Axes.fill_between   Axes.fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, *, data=None, **kwargs)[source]

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.  Parameters

xarray (length N)

The x coordinates of the nodes defining the curves.
y1array (length N) or scalar

The y coordinates of the nodes defining the first curve.
y2array (length N) or scalar, default: 0

The y coordinates of the nodes defining the second curve.
wherearray of bool (length N), optional

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.
interpolatebool, default: False

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.
step{'pre', 'post', 'mid'}, optional

Define step if the filling should be a step function, i.e. constant in between x. The value determines where the step will occur:  'pre': The y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i]. 'post': The y value is continued constantly to the right from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i]. 'mid': Steps occur half-way between the x positions.     Returns
 PolyCollection

A PolyCollection containing the plotted polygons.    Other Parameters

dataindexable object, optional

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  **kwargs

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

Fill between two sets of y-values.  fill_betweenx

Fill between two sets of x-values.
  Examples using matplotlib.axes.Axes.fill_between

   Fill Between and Alpha

   Filling the area between lines

   fill_between(x, y1, y2)


matplotlib.axes.Axes.fill_betweenx   Axes.fill_betweenx(y, x1, x2=0, where=None, step=None, interpolate=False, *, data=None, **kwargs)[source]

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.  Parameters

yarray (length N)

The y coordinates of the nodes defining the curves.
x1array (length N) or scalar

The x coordinates of the nodes defining the first curve.
x2array (length N) or scalar, default: 0

The x coordinates of the nodes defining the second curve.
wherearray of bool (length N), optional

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.
interpolatebool, default: False

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.
step{'pre', 'post', 'mid'}, optional

Define step if the filling should be a step function, i.e. constant in between y. The value determines where the step will occur:  'pre': The y value is continued constantly to the left from every x position, i.e. the interval (x[i-1], x[i]] has the value y[i]. 'post': The y value is continued constantly to the right from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i]. 'mid': Steps occur half-way between the x positions.     Returns
 PolyCollection

A PolyCollection containing the plotted polygons.    Other Parameters

dataindexable object, optional

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  **kwargs

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

Fill between two sets of y-values.  fill_betweenx

Fill between two sets of x-values.
  Examples using matplotlib.axes.Axes.fill_betweenx

   Fill Betweenx Demo


matplotlib.axes.Axes.findobj   Axes.findobj(match=None, include_self=True)[source]

Find artist objects. Recursively find all Artist instances contained in the artist.  Parameters
 match

A filter criterion for the matches. This can be
None: Return all objects contained in artist. A function with signature def match(artist: Artist) -> bool. The result will only contain artists for which the function returns True. A class instance: e.g., Line2D. The result will only contain artists of this class or its subclasses (isinstance check).
include_selfbool

Include self in the list to be checked for a match.    Returns
 list of Artist


matplotlib.axes.Axes.format_coord   Axes.format_coord(x, y)[source]

Return a format string formatting the x, y coordinates.


matplotlib.axes.Axes.format_cursor_data   Axes.format_cursor_data(data)[source]

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  get_cursor_data


matplotlib.axes.Axes.format_xdata   Axes.format_xdata(x)[source]

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.


matplotlib.axes.Axes.format_ydata   Axes.format_ydata(y)[source]

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.


matplotlib.axes.Axes.get_adjustable   Axes.get_adjustable()[source]

Return whether the Axes will adjust its physical dimension ('box') or its data limits ('datalim') to achieve the desired aspect ratio.  See also  matplotlib.axes.Axes.set_adjustable

Set how the Axes adjusts to achieve the required aspect ratio.  matplotlib.axes.Axes.set_aspect

For a description of aspect handling.


matplotlib.axes.Axes.get_anchor   Axes.get_anchor()[source]

Get the anchor location.  See also  matplotlib.axes.Axes.set_anchor

for a description of the anchor.  matplotlib.axes.Axes.set_aspect

for a description of aspect handling.


matplotlib.axes.Axes.get_aspect   Axes.get_aspect()[source]

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


matplotlib.axes.Axes.get_autoscale_on   Axes.get_autoscale_on()[source]

Return True if each axis is autoscaled, False otherwise.


matplotlib.axes.Axes.get_autoscalex_on   Axes.get_autoscalex_on()[source]

Return whether the x-axis is autoscaled.


matplotlib.axes.Axes.get_autoscaley_on   Axes.get_autoscaley_on()[source]

Return whether the y-axis is autoscaled.


matplotlib.axes.Axes.get_axes_locator   Axes.get_axes_locator()[source]

Return the axes_locator.


matplotlib.axes.Axes.get_axisbelow   Axes.get_axisbelow()[source]

Get whether axis ticks and gridlines are above or below most artists.  Returns
 bool or 'line'
    See also  set_axisbelow


matplotlib.axes.Axes.get_box_aspect   Axes.get_box_aspect()[source]

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  matplotlib.axes.Axes.set_box_aspect

for a description of box aspect.  matplotlib.axes.Axes.set_aspect

for a description of aspect handling.


matplotlib.axes.Axes.get_children   Axes.get_children()[source]

Return a list of the child Artists of this Artist.


matplotlib.axes.Axes.get_cursor_data   Axes.get_cursor_data(event)[source]

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.  Parameters

eventmatplotlib.backend_bases.MouseEvent

    See also  format_cursor_data


matplotlib.axes.Axes.get_data_ratio   Axes.get_data_ratio()[source]

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


matplotlib.axes.Axes.get_default_bbox_extra_artists   Axes.get_default_bbox_extra_artists()[source]

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).


matplotlib.axes.Axes.get_facecolor   Axes.get_facecolor()[source]

Get the facecolor of the Axes.


matplotlib.axes.Axes.get_frame_on   Axes.get_frame_on()[source]

Get whether the Axes rectangle patch is drawn.


matplotlib.axes.Axes.get_images   Axes.get_images()[source]

Return a list of AxesImages contained by the Axes.


matplotlib.axes.Axes.get_legend   Axes.get_legend()[source]

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


matplotlib.axes.Axes.get_legend_handles_labels   Axes.get_legend_handles_labels(legend_handler_map=None)[source]

Return handles and labels for legend ax.legend() is equivalent to h, l = ax.get_legend_handles_labels()
ax.legend(h, l)

  Examples using matplotlib.axes.Axes.get_legend_handles_labels

   Legend guide


matplotlib.axes.Axes.get_lines   Axes.get_lines()[source]

Return a list of lines contained by the Axes.


matplotlib.axes.Axes.get_navigate   Axes.get_navigate()[source]

Get whether the Axes responds to navigation commands.


matplotlib.axes.Axes.get_navigate_mode   Axes.get_navigate_mode()[source]

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


matplotlib.axes.Axes.get_position   Axes.get_position(original=False)[source]

Return the position of the Axes within the figure as a Bbox.  Parameters

originalbool

If True, return the original position. Otherwise return the active position. For an explanation of the positions see set_position.    Returns
 Bbox

  Examples using matplotlib.axes.Axes.get_position

   Contour Demo


matplotlib.axes.Axes.get_rasterization_zorder   Axes.get_rasterization_zorder()[source]

Return the zorder value below which artists will be rasterized.


matplotlib.axes.Axes.get_renderer_cache   Axes.get_renderer_cache()[source]


matplotlib.axes.Axes.get_shared_x_axes   Axes.get_shared_x_axes()[source]

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


matplotlib.axes.Axes.get_shared_y_axes   Axes.get_shared_y_axes()[source]

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


matplotlib.axes.Axes.get_tightbbox   Axes.get_tightbbox(renderer, call_axes_locator=True, bbox_extra_artists=None, *, for_layout_only=False)[source]

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.  Parameters

rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())
bbox_extra_artistslist of Artist or None

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.
call_axes_locatorbool, default: True

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.
for_layout_onlydefault: False

The bounding box will not include the x-extent of the title and the xlabel, or the y-extent of the ylabel.    Returns
 BboxBase

Bounding box in figure pixel coordinates.      See also  matplotlib.axes.Axes.get_window_extent
matplotlib.axis.Axis.get_tightbbox
matplotlib.spines.Spine.get_window_extent


matplotlib.axes.Axes.get_title   Axes.get_title(loc='center')[source]

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.  Parameters

loc{'center', 'left', 'right'}, str, default: 'center'

Which title to return.    Returns
 str

The title text string.


matplotlib.axes.Axes.get_transformed_clip_path_and_affine   Axes.get_transformed_clip_path_and_affine()[source]

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


matplotlib.axes.Axes.get_window_extent   Axes.get_window_extent(*args, **kwargs)[source]

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  matplotlib.axes.Axes.get_tightbbox
matplotlib.axis.Axis.get_tightbbox
matplotlib.spines.Spine.get_window_extent


matplotlib.axes.Axes.get_xaxis   Axes.get_xaxis()[source]

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


matplotlib.axes.Axes.get_xaxis_text1_transform   Axes.get_xaxis_text1_transform(pad_points)[source]

 Returns

transformTransform

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
valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}

The text vertical alignment.
halign{'center', 'left', 'right'}

The text horizontal alignment.     Notes 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.


matplotlib.axes.Axes.get_xaxis_text2_transform   Axes.get_xaxis_text2_transform(pad_points)[source]

 Returns

transformTransform

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
valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}

The text vertical alignment.
halign{'center', 'left', 'right'}

The text horizontal alignment.     Notes 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.


matplotlib.axes.Axes.get_xaxis_transform   Axes.get_xaxis_transform(which='grid')[source]

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.
  Examples using matplotlib.axes.Axes.get_xaxis_transform

   Filling the area between lines

   hlines and vlines

   Boxplots

   Scale invariant angle label

   Centered spines with arrows

   Transformations Tutorial


matplotlib.axes.Axes.get_xbound   Axes.get_xbound()[source]

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

get_xlim, set_xlim

invert_xaxis, xaxis_inverted


matplotlib.axes.Axes.get_xgridlines   Axes.get_xgridlines()[source]

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


matplotlib.axes.Axes.get_xlabel   Axes.get_xlabel()[source]

Get the xlabel text string.


matplotlib.axes.Axes.get_xlim   Axes.get_xlim()[source]

Return the x-axis view limits.  Returns

left, right(float, float)

The current x-axis limits in data coordinates.      See also  set_xlim

set_xbound, get_xbound

invert_xaxis, xaxis_inverted

  Notes The x-axis may be inverted, in which case the left value will be greater than the right value.
  Examples using matplotlib.axes.Axes.get_xlim

   Decay


matplotlib.axes.Axes.get_xmajorticklabels   Axes.get_xmajorticklabels()[source]

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


matplotlib.axes.Axes.get_xminorticklabels   Axes.get_xminorticklabels()[source]

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


matplotlib.axes.Axes.get_xscale   Axes.get_xscale()[source]

Return the xaxis' scale (as a str).


matplotlib.axes.Axes.get_xticklabels   Axes.get_xticklabels(minor=False, which=None)[source]

Get the xaxis' tick labels.  Parameters

minorbool

Whether to return the minor or the major ticklabels.
whichNone, ('minor', 'major', 'both')

Overrides minor. Selects which ticklabels to return    Returns
 list of Text

   Notes The tick label strings are not populated until a draw method has been called. See also: draw and draw.
  Examples using matplotlib.axes.Axes.get_xticklabels

   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


matplotlib.axes.Axes.get_xticklines   Axes.get_xticklines(minor=False)[source]

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


matplotlib.axes.Axes.get_xticks   Axes.get_xticks(*, minor=False)[source]

Return the xaxis' tick locations in data coordinates.


matplotlib.axes.Axes.get_yaxis   Axes.get_yaxis()[source]

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


matplotlib.axes.Axes.get_yaxis_text1_transform   Axes.get_yaxis_text1_transform(pad_points)[source]

 Returns

transformTransform

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
valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}

The text vertical alignment.
halign{'center', 'left', 'right'}

The text horizontal alignment.     Notes 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.


matplotlib.axes.Axes.get_yaxis_text2_transform   Axes.get_yaxis_text2_transform(pad_points)[source]

 Returns

transformTransform

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
valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}

The text vertical alignment.
halign{'center', 'left', 'right'}

The text horizontal alignment.     Notes 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.


matplotlib.axes.Axes.get_yaxis_transform   Axes.get_yaxis_transform(which='grid')[source]

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.
  Examples using matplotlib.axes.Axes.get_yaxis_transform

   Centered spines with arrows

   Connect Simple01

   Transformations Tutorial


matplotlib.axes.Axes.get_ybound   Axes.get_ybound()[source]

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

get_ylim, set_ylim

invert_yaxis, yaxis_inverted


matplotlib.axes.Axes.get_ygridlines   Axes.get_ygridlines()[source]

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


matplotlib.axes.Axes.get_ylabel   Axes.get_ylabel()[source]

Get the ylabel text string.


matplotlib.axes.Axes.get_ylim   Axes.get_ylim()[source]

Return the y-axis view limits.  Returns

bottom, top(float, float)

The current y-axis limits in data coordinates.      See also  set_ylim

set_ybound, get_ybound

invert_yaxis, yaxis_inverted

  Notes The y-axis may be inverted, in which case the bottom value will be greater than the top value.
  Examples using matplotlib.axes.Axes.get_ylim

   Line, Poly and RegularPoly Collection with autoscaling


matplotlib.axes.Axes.get_ymajorticklabels   Axes.get_ymajorticklabels()[source]

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


matplotlib.axes.Axes.get_yminorticklabels   Axes.get_yminorticklabels()[source]

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


matplotlib.axes.Axes.get_yscale   Axes.get_yscale()[source]

Return the yaxis' scale (as a str).


matplotlib.axes.Axes.get_yticklabels   Axes.get_yticklabels(minor=False, which=None)[source]

Get the yaxis' tick labels.  Parameters

minorbool

Whether to return the minor or the major ticklabels.
whichNone, ('minor', 'major', 'both')

Overrides minor. Selects which ticklabels to return    Returns
 list of Text

   Notes The tick label strings are not populated until a draw method has been called. See also: draw and draw.
  Examples using matplotlib.axes.Axes.get_yticklabels

   Fill Between and Alpha

   Programmatically controlling subplot adjustment


matplotlib.axes.Axes.get_yticklines   Axes.get_yticklines(minor=False)[source]

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


matplotlib.axes.Axes.get_yticks   Axes.get_yticks(*, minor=False)[source]

Return the yaxis' tick locations in data coordinates.


matplotlib.axes.Axes.grid   Axes.grid(visible=None, which='major', axis='both', **kwargs)[source]

Configure the grid lines.  Parameters

visiblebool or None, optional

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.
which{'major', 'minor', 'both'}, optional

The grid lines to apply the changes on.
axis{'both', 'x', 'y'}, optional

The axis to apply the changes on.
**kwargsLine2D properties

Define the line properties of the grid, e.g.: grid(color='r', linestyle='-', linewidth=2)
 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       Notes 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.
  Examples using matplotlib.axes.Axes.grid

   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


matplotlib.axes.Axes.has_data   Axes.has_data()[source]

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.


matplotlib.axes.Axes.have_units   Axes.have_units()[source]

Return whether units are set on any axis.


matplotlib.axes.Axes.hexbin   Axes.hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', yscale='linear', extent=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors='face', reduce_C_function=<function mean>, mincnt=None, marginals=False, *, data=None, **kwargs)[source]

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.  Parameters

x, yarray-like

The data positions. x and y must be of the same length.
Carray-like, optional

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.
gridsizeint or (int, int), default: 100

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.
bins'log' or int or sequence, default: None

Discretization of the hexagon values.  If None, no binning is applied; the color of each hexagon directly corresponds to its count value. If 'log', use a logarithmic scale for the colormap. Internally, \(log_{10}(i+1)\) is used to determine the hexagon color. This is equivalent to norm=LogNorm(). If an integer, divide the counts in the specified number of bins, and color the hexagons accordingly. If a sequence of values, the values of the lower bound of the bins to be used.
xscale{'linear', 'log'}, default: 'linear'

Use a linear or log10 scale on the horizontal axis.
yscale{'linear', 'log'}, default: 'linear'

Use a linear or log10 scale on the vertical axis.
mincntint > 0, default: None

If not None, only display cells with more than mincnt number of points in the cell.
marginalsbool, default: False

If marginals is True, plot the marginal density as colormapped rectangles along the bottom of the x-axis and left of the y-axis.
extent4-tuple of float, default: None

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).    Returns
 PolyCollection

A PolyCollection defining the hexagonal bins.
PolyCollection.get_offsets contains a Mx2 array containing the x, y positions of the M hexagon centers.
PolyCollection.get_array contains the values of the M hexagons.  If marginals is True, horizontal bar and vertical bar (both PolyCollections) will be attached to the return collection as attributes hbar and vbar.    Other Parameters

cmapstr or Colormap, default: rcParams["image.cmap"] (default: 'viridis')

The Colormap instance or registered colormap name used to map the bin values to colors.
normNormalize, optional

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.
vmin, vmaxfloat, default: None

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.
alphafloat between 0 and 1, optional

The alpha blending value, between 0 (transparent) and 1 (opaque).
linewidthsfloat, default: None

If None, defaults to 1.0.
edgecolors{'face', 'none', None} or color, default: 'face'

The color of the hexagon edges. Possible values are:  'face': Draw the edges in the same color as the fill color. 'none': No edges are drawn. This can sometimes lead to unsightly unpainted pixels between the hexagons.
None: Draw outlines in the default color. An explicit color.
reduce_C_functioncallable, default: numpy.mean

The function to aggregate C within the bins. It is ignored if C is not given. This must have the signature: def reduce_C_function(C: array) -> float
 Commonly used functions are:
numpy.mean: average of the points
numpy.sum: integral of the point values
numpy.amax: value taken from the largest point
dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception): x, y, C
**kwargsPolyCollection properties

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  hist2d

2D histogram rectangular bins
  Examples using matplotlib.axes.Axes.hexbin

   Hexagonal binned plot

   hexbin(x, y, C)


matplotlib.axes.Axes.hist   Axes.hist(x, bins=None, range=None, density=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, *, data=None, **kwargs)[source]

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.  Parameters

x(n,) array or sequence of (n,) arrays

Input values, this takes either a single array or a sequence of arrays which are not required to be of the same length.
binsint or sequence or str, default: rcParams["hist.bins"] (default: 10)

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: [1, 2, 3, 4]
 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'.
rangetuple or None, default: None

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.
densitybool, default: False

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.
weights(n,) array-like or None, default: None

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) counts, bins = np.histogram(data)
plt.hist(bins[:-1], bins, weights=counts)
 (or you may alternatively use bar()).
cumulativebool or -1, default: False

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.
bottomarray-like, scalar, or None, default: None

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.
histtype{'bar', 'barstacked', 'step', 'stepfilled'}, default: 'bar'

The type of histogram to draw.  'bar' is a traditional bar-type histogram. If multiple data are given the bars are arranged side by side. 'barstacked' is a bar-type histogram where multiple data are stacked on top of each other. 'step' generates a lineplot that is by default unfilled. 'stepfilled' generates a lineplot that is by default filled.
align{'left', 'mid', 'right'}, default: 'mid'

The horizontal alignment of the histogram bars.  'left': bars are centered on the left bin edges. 'mid': bars are centered between the bin edges. 'right': bars are centered on the right bin edges.
orientation{'vertical', 'horizontal'}, default: 'vertical'

If 'horizontal', barh will be used for bar-type histograms and the bottom kwarg will be the left edges.
rwidthfloat or None, default: None

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'.
logbool, default: False

If True, the histogram axis will be set to a log scale.
colorcolor or array-like of colors or None, default: None

Color or sequence of colors, one per dataset. Default (None) uses the standard line color sequence.
labelstr or None, default: None

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.
stackedbool, default: False

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'    Returns

narray or list of arrays

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.
binsarray

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.
patchesBarContainer or list of a single Polygon or list of such objects

Container of individual artists used to create the histogram or list of such containers if there are multiple input datasets.    Other Parameters

dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception): x, weights  **kwargs

Patch properties      See also  hist2d

2D histogram with rectangular bins  hexbin

2D histogram with hexagonal bins    Notes For large numbers of bins (>1000), 'step' and 'stepfilled' can be significantly faster than 'bar' and 'barstacked'.
  Examples using matplotlib.axes.Axes.hist

   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)


matplotlib.axes.Axes.hist2d   Axes.hist2d(x, y, bins=10, range=None, density=False, weights=None, cmin=None, cmax=None, *, data=None, **kwargs)[source]

Make a 2D histogram plot.  Parameters

x, yarray-like, shape (n, )

Input values
binsNone or int or [int, int] or array-like or [array, array]

The bin specification:  If int, the number of bins for the two dimensions (nx=ny=bins). If [int, int], the number of bins in each dimension (nx, ny = bins). If array-like, the bin edges for the two dimensions (x_edges=y_edges=bins). If [array, array], the bin edges in each dimension (x_edges, y_edges = bins).  The default value is 10.
rangearray-like shape(2, 2), optional

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.
densitybool, default: False

Normalize histogram. See the documentation for the density parameter of hist for more details.
weightsarray-like, shape (n, ), optional

An array of values w_i weighing each sample (x_i, y_i).
cmin, cmaxfloat, default: None

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.    Returns

h2D array

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.
xedges1D array

The bin edges along the x axis.
yedges1D array

The bin edges along the y axis.
imageQuadMesh

  Other Parameters

cmapColormap or str, optional

A colors.Colormap instance. If not set, use rc settings.
normNormalize, optional

A colors.Normalize instance is used to scale luminance data to [0, 1]. If not set, defaults to colors.Normalize().
vmin/vmaxNone or scalar, optional

Arguments passed to the Normalize instance.
alpha0 <= scalar <= 1 or None, optional

The alpha blending value.
dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception): x, y, weights  **kwargs

Additional parameters are passed along to the pcolormesh method and QuadMesh constructor.      See also  hist

1D histogram plotting  hexbin

2D histogram with hexagonal bins    Notes  Currently hist2d calculates its own axis limits, and any limits previously set are ignored. Rendering the histogram with a logarithmic color scale is accomplished by passing a colors.LogNorm instance to the norm keyword argument. Likewise, power-law normalization (similar in effect to gamma correction) can be accomplished with colors.PowerNorm.
  Examples using matplotlib.axes.Axes.hist2d

   Histograms

   Exploring normalizations

   hist2d(x, y)


matplotlib.axes.Axes.hlines   Axes.hlines(y, xmin, xmax, colors=None, linestyles='solid', label='', *, data=None, **kwargs)[source]

Plot horizontal lines at each y from xmin to xmax.  Parameters

yfloat or array-like

y-indexes where to plot the lines.
xmin, xmaxfloat or array-like

Respective beginning and end of each line. If scalars are provided, all lines will have same length.
colorslist of colors, default: rcParams["lines.color"] (default: 'C0')

linestyles{'solid', 'dashed', 'dashdot', 'dotted'}, optional

labelstr, default: ''

  Returns
 LineCollection
  Other Parameters

dataindexable object, optional

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
**kwargsLineCollection properties.

    See also  vlines

vertical lines  axhline

horizontal line across the Axes
  Examples using matplotlib.axes.Axes.hlines

   hlines and vlines

   Specifying Colors


matplotlib.axes.Axes.imshow   Axes.imshow(X, cmap=None, norm=None, *, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, interpolation_stage=None, filternorm=True, filterrad=4.0, resample=None, url=None, data=None, **kwargs)[source]

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').  Parameters

Xarray-like or PIL image

The image data. Supported array shapes are:  (M, N): an image with scalar data. The values are mapped to colors using normalization and a colormap. See parameters norm, cmap, vmin, vmax. (M, N, 3): an image with RGB values (0-1 float or 0-255 int). (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency.  The first two dimensions (M, N) define the rows and columns of the image. Out-of-range RGB(A) values are clipped.
cmapstr or Colormap, default: rcParams["image.cmap"] (default: 'viridis')

The Colormap instance or registered colormap name used to map scalar data to colors. This parameter is ignored for RGB(A) data.
normNormalize, optional

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.
aspect{'equal', 'auto'} or float, default: rcParams["image.aspect"] (default: 'equal')

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.  'equal': Ensures an aspect ratio of 1. Pixels will be square (unless pixel sizes are explicitly made non-square in data coordinates using extent). 'auto': The Axes is kept fixed and the aspect is adjusted so that the data fit in the Axes. In general, this will result in non-square pixels.
interpolationstr, default: rcParams["image.interpolation"] (default: 'antialiased')

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.
interpolation_stage{'data', 'rgba'}, default: 'data'

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).
alphafloat or array-like, optional

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.
vmin, vmaxfloat, optional

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.
origin{'upper', 'lower'}, default: rcParams["image.origin"] (default: 'upper')

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.
extentfloats (left, right, bottom, top), optional

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:  For origin == 'upper' the default is (-0.5, numcols-0.5, numrows-0.5, -0.5). For origin == 'lower' the default is (-0.5, numcols-0.5, -0.5, numrows-0.5).  See the origin and extent in imshow tutorial for examples and a more detailed description.
filternormbool, default: True

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.
filterradfloat > 0, default: 4.0

The filter radius for filters that have a radius parameter, i.e. when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
resamplebool, default: rcParams["image.resample"] (default: True)

When True, use a full resampling method. When False, only resample when the output image is larger than the input image.
urlstr, optional

Set the url of the created AxesImage. See Artist.set_url.    Returns
 AxesImage
  Other Parameters

dataindexable object, optional

If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
**kwargsArtist properties

These parameters are passed on to the constructor of the AxesImage artist.      See also  matshow

Plot a matrix or an array as an image.    Notes 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:  Straight (unassociated) alpha: R, G, and B channels represent the color of the pixel, disregarding its opacity. Premultiplied (associated) alpha: R, G, and B channels represent the color of the pixel, adjusted for its opacity by multiplication.  imshow expects RGB images adopting the straight (unassociated) alpha representation.
  Examples using matplotlib.axes.Axes.imshow

   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)


matplotlib.axes.Axes.in_axes   Axes.in_axes(mouseevent)[source]

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


matplotlib.axes.Axes.indicate_inset   Axes.indicate_inset(bounds, inset_ax=None, *, transform=None, facecolor='none', edgecolor='0.5', alpha=0.5, zorder=4.99, **kwargs)[source]

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).  Parameters

bounds[x0, y0, width, height]

Lower-left corner of rectangle to be marked, and its width and height.
inset_axAxes

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.
transformTransform

Transform for the rectangle coordinates. Defaults to ax.transAxes, i.e. the units of rect are in Axes-relative coordinates.
facecolorcolor, default: 'none'

Facecolor of the rectangle.
edgecolorcolor, default: '0.5'

Color of the rectangle and color of the connecting lines.
alphafloat, default: 0.5

Transparency of the rectangle and connector lines.
zorderfloat, default: 4.99

Drawing order of the rectangle and connector lines. The default, 4.99, is just below the default level of inset Axes.  **kwargs

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      Returns

rectangle_patchpatches.Rectangle

The indicator frame.
connector_lines4-tuple of patches.ConnectionPatch

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.


matplotlib.axes.Axes.indicate_inset_zoom   Axes.indicate_inset_zoom(inset_ax, **kwargs)[source]

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.  Parameters

inset_axAxes

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.  **kwargs

Other keyword arguments are passed on to Axes.indicate_inset    Returns

rectangle_patchpatches.Rectangle

Rectangle artist.
connector_lines4-tuple of patches.ConnectionPatch

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.
  Examples using matplotlib.axes.Axes.indicate_inset_zoom

   Zoom region inset axes


matplotlib.axes.Axes.inset_axes   Axes.inset_axes(bounds, *, transform=None, zorder=5, **kwargs)[source]

Add a child inset Axes to this existing Axes.  Parameters

bounds[x0, y0, width, height]

Lower-left corner of inset Axes, and its width and height.
transformTransform

Defaults to ax.transAxes, i.e. the units of rect are in Axes-relative coordinates.
zordernumber

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.  **kwargs

Other keyword arguments are passed on to the child Axes.    Returns
 ax

The created Axes instance.      Warning This method is experimental as of 3.0, and the API may change.  Examples This example makes two inset Axes, the first is in Axes-relative coordinates, and the second in data-coordinates: fig, ax = plt.subplots()
ax.plot(range(10))
axin1 = ax.inset_axes([0.8, 0.1, 0.15, 0.15])
axin2 = ax.inset_axes(
        [5, 7, 2.3, 2.3], transform=ax.transData)

  Examples using matplotlib.axes.Axes.inset_axes

   Placing Colorbars

   Zoom region inset axes


matplotlib.axes.Axes.invert_xaxis   Axes.invert_xaxis()[source]

Invert the x-axis.  See also  xaxis_inverted

get_xlim, set_xlim

get_xbound, set_xbound


matplotlib.axes.Axes.invert_yaxis   Axes.invert_yaxis()[source]

Invert the y-axis.  See also  yaxis_inverted

get_ylim, set_ylim

get_ybound, set_ybound

  Examples using matplotlib.axes.Axes.invert_yaxis

   Bar Label Demo

   Horizontal bar chart

   Marker reference