doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
matplotlib.axes.Axes.axhspan Axes.axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs)[source]
Add a horizontal span (rectangle) across the Axes. The rectangle spans from ymin to ymax vertically, and, by default, the whole x-axis horizontally. The x-span can be set using xmin (default: 0) and xmax (default: 1) which are in axis units; e.g. xmin = 0.5 always refers to the middle of the x-axis regardless of the limits set by set_xlim. Parameters
yminfloat
Lower y-coordinate of the span, in data units.
ymaxfloat
Upper y-coordinate of the span, in data units.
xminfloat, default: 0
Lower x-coordinate of the span, in x-axis (0-1) units.
xmaxfloat, default: 1
Upper x-coordinate of the span, in x-axis (0-1) units. Returns
Polygon
Horizontal span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters
**kwargsPolygon 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 or None
capstyle CapStyle or {'butt', 'projecting', 'round'}
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
closed bool
color color
edgecolor or ec color or None
facecolor or fc color or None
figure Figure
fill bool
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
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
xy (N, 2) array-like
zorder float See also axvspan
Add a vertical span across the Axes.
Examples using matplotlib.axes.Axes.axhspan
axhspan Demo
Transformations Tutorial | matplotlib._as_gen.matplotlib.axes.axes.axhspan |
matplotlib.axes.Axes.axis Axes.axis(*args, emit=True, **kwargs)[source]
Convenience method to get or set some axis properties. Call signatures: xmin, xmax, ymin, ymax = axis()
xmin, xmax, ymin, ymax = axis([xmin, xmax, ymin, ymax])
xmin, xmax, ymin, ymax = axis(option)
xmin, xmax, ymin, ymax = axis(**kwargs)
Parameters
xmin, xmax, ymin, ymaxfloat, optional
The axis limits to be set. This can also be achieved using ax.set(xlim=(xmin, xmax), ylim=(ymin, ymax))
optionbool or str
If a bool, turns axis lines and labels on or off. If a string, possible values are:
Value Description
'on' Turn on axis lines and labels. Same as True.
'off' Turn off axis lines and labels. Same as False.
'equal' Set equal scaling (i.e., make circles circular) by changing axis limits. This is the same as ax.set_aspect('equal', adjustable='datalim'). Explicit data limits may not be respected in this case.
'scaled' Set equal scaling (i.e., make circles circular) by changing dimensions of the plot box. This is the same as ax.set_aspect('equal', adjustable='box', anchor='C'). Additionally, further autoscaling will be disabled.
'tight' Set limits just large enough to show all data, then disable further autoscaling.
'auto' Automatic scaling (fill plot box with data).
'image' 'scaled' with axis limits equal to data limits.
'square' Square plot; similar to 'scaled', but initially forcing xmax-xmin == ymax-ymin.
emitbool, default: True
Whether observers are notified of the axis limit change. This option is passed on to set_xlim and set_ylim. Returns
xmin, xmax, ymin, ymaxfloat
The axis limits. See also matplotlib.axes.Axes.set_xlim
matplotlib.axes.Axes.set_ylim
Examples using matplotlib.axes.Axes.axis
Clipping images with patches
Basic pie chart
Bar of pie
Hatch style reference
PathPatch object
ggplot style sheet
Parasite Simple2
Simple Axisline4
Axis Direction
axis_direction demo
Axis line styles
mpl_toolkits.axisartist.floating_axes features
Parasite Axes demo
Parasite axis demo
Ticklabel alignment
Ticklabel direction
Simple Axis Direction01
Simple Axis Direction03
Simple Axis Pad
Custom spines with axisartist
Simple Axisline
Simple Axisline3
Packed-bubble chart
TickedStroke patheffect
MRI
MRI With EEG
Basic Usage
Specifying Colors
Text in Matplotlib Plots | matplotlib._as_gen.matplotlib.axes.axes.axis |
matplotlib.axes.Axes.axline Axes.axline(xy1, xy2=None, *, slope=None, **kwargs)[source]
Add an infinitely long straight line. The line can be defined either by two points xy1 and xy2, or by one point xy1 and a slope. This draws a straight line "on the screen", regardless of the x and y scales, and is thus also suitable for drawing exponential decays in semilog plots, power laws in loglog plots, etc. However, slope should only be used with linear scales; It has no clear meaning for all other scales, and thus the behavior is undefined. Please specify the line using the points xy1, xy2 for non-linear scales. The transform keyword argument only applies to the points xy1, xy2. The slope (if given) is always in data coordinates. This can be used e.g. with ax.transAxes for drawing grid lines with a fixed slope. Parameters
xy1, xy2(float, float)
Points for the line to pass through. Either xy2 or slope has to be given.
slopefloat, optional
The slope of the line. Either xy2 or slope has to be given. Returns
Line2D
Other Parameters
**kwargs
Valid kwargs 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 See also axhline
for horizontal lines axvline
for vertical lines Examples Draw a thick red line passing through (0, 0) and (1, 1): >>> axline((0, 0), (1, 1), linewidth=4, color='r')
Examples using matplotlib.axes.Axes.axline
axhspan Demo
Anscombe's quartet | matplotlib._as_gen.matplotlib.axes.axes.axline |
matplotlib.axes.Axes.axvline Axes.axvline(x=0, ymin=0, ymax=1, **kwargs)[source]
Add a vertical line across the Axes. Parameters
xfloat, default: 0
x position in data coordinates of the vertical line.
yminfloat, default: 0
Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.
ymaxfloat, default: 1
Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot. Returns
Line2D
Other Parameters
**kwargs
Valid keyword arguments are Line2D properties, with the exception of 'transform':
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 vlines
Add vertical lines in data coordinates. axvspan
Add a vertical span (rectangle) across the axis. axline
Add a line with an arbitrary slope. Examples
draw a thick red vline at x = 0 that spans the yrange: >>> axvline(linewidth=4, color='r')
draw a default vline at x = 1 that spans the yrange: >>> axvline(x=1)
draw a default vline at x = .5 that spans the middle half of the yrange: >>> axvline(x=.5, ymin=0.25, ymax=0.75)
Examples using matplotlib.axes.Axes.axvline
axhspan Demo
Plot a confidence ellipse of a two-dimensional dataset
Usetex Baseline Test
Cross hair cursor
SkewT-logP diagram: using transforms and custom projections
The Lifecycle of a Plot
Transformations Tutorial | matplotlib._as_gen.matplotlib.axes.axes.axvline |
matplotlib.axes.Axes.axvspan Axes.axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)[source]
Add a vertical span (rectangle) across the Axes. The rectangle spans from xmin to xmax horizontally, and, by default, the whole y-axis vertically. The y-span can be set using ymin (default: 0) and ymax (default: 1) which are in axis units; e.g. ymin = 0.5 always refers to the middle of the y-axis regardless of the limits set by set_ylim. Parameters
xminfloat
Lower x-coordinate of the span, in data units.
xmaxfloat
Upper x-coordinate of the span, in data units.
yminfloat, default: 0
Lower y-coordinate of the span, in y-axis units (0-1).
ymaxfloat, default: 1
Upper y-coordinate of the span, in y-axis units (0-1). Returns
Polygon
Vertical span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters
**kwargsPolygon 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 or None
capstyle CapStyle or {'butt', 'projecting', 'round'}
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
closed bool
color color
edgecolor or ec color or None
facecolor or fc color or None
figure Figure
fill bool
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
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
xy (N, 2) array-like
zorder float See also axhspan
Add a horizontal span across the Axes. Examples Draw a vertical, green, translucent rectangle from x = 1.25 to x = 1.55 that spans the yrange of the Axes. >>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
Examples using matplotlib.axes.Axes.axvspan
axhspan Demo
Transformations Tutorial | matplotlib._as_gen.matplotlib.axes.axes.axvspan |
matplotlib.axes.Axes.bar Axes.bar(x, height, width=0.8, bottom=None, *, align='center', data=None, **kwargs)[source]
Make a bar plot. The bars are positioned at x with the given alignment. Their dimensions are given by height and width. The vertical baseline is bottom (default 0). Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar. Parameters
xfloat or array-like
The x coordinates of the bars. See also align for the alignment of the bars to the coordinates.
heightfloat or array-like
The height(s) of the bars.
widthfloat or array-like, default: 0.8
The width(s) of the bars.
bottomfloat or array-like, default: 0
The y coordinate(s) of the bars bases.
align{'center', 'edge'}, default: 'center'
Alignment of the bars to the x coordinates: 'center': Center the base on the x positions. 'edge': Align the left edges of the bars with the x positions. To align the bars on the right edge pass a negative width and align='edge'. Returns
BarContainer
Container with all the bars and optionally errorbars. Other Parameters
colorcolor or list of color, optional
The colors of the bar faces.
edgecolorcolor or list of color, optional
The colors of the bar edges.
linewidthfloat or array-like, optional
Width of the bar edge(s). If 0, don't draw edges.
tick_labelstr or list of str, optional
The tick labels of the bars. Default: None (Use default numeric labels.)
xerr, yerrfloat or array-like of shape(N,) or shape(2, N), optional
If not None, add horizontal / vertical errorbars to the bar tips. The values are +/- sizes relative to the data: scalar: symmetric +/- values for all bars shape(N,): symmetric +/- values for each bar 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. (Default) See Different ways of specifying error bars for an example on the usage of xerr and yerr.
ecolorcolor or list of color, default: 'black'
The line color of the errorbars.
capsizefloat, default: rcParams["errorbar.capsize"] (default: 0.0)
The length of the error bar caps in points.
error_kwdict, optional
Dictionary of kwargs to be passed to the errorbar method. Values of ecolor or capsize defined here take precedence over the independent kwargs.
logbool, default: False
If True, set the y-axis to be log scale.
dataindexable object, optional
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception).
**kwargsRectangle 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
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 See also barh
Plot a horizontal bar plot. Notes Stacked bars can be achieved by passing individual bottom values per bar. See Stacked bar chart.
Examples using matplotlib.axes.Axes.bar
Bar Label Demo
Stacked bar chart
Grouped bar chart with labels
Hat graph
Bar of pie
Nested pie charts
Bar chart on polar axis
Legend Demo
ggplot style sheet
mpl_toolkits.axisartist.floating_axes features
XKCD
Create 2D bar graphs in different planes
Log Bar
Custom Ticker1
Group barchart with units
Basic Usage
Artist tutorial
Path Tutorial
bar(x, height) / barh(y, width) | matplotlib._as_gen.matplotlib.axes.axes.bar |
matplotlib.axes.Axes.bar_label Axes.bar_label(container, labels=None, *, fmt='%g', label_type='edge', padding=0, **kwargs)[source]
Label a bar plot. Adds labels to bars in the given BarContainer. You may need to adjust the axis limits to fit the labels. Parameters
containerBarContainer
Container with all the bars and optionally errorbars, likely returned from bar or barh.
labelsarray-like, optional
A list of label texts, that should be displayed. If not given, the label texts will be the data values formatted with fmt.
fmtstr, default: '%g'
A format string for the label.
label_type{'edge', 'center'}, default: 'edge'
The label type. Possible values: 'edge': label placed at the end-point of the bar segment, and the value displayed will be the position of that end-point. 'center': label placed in the center of the bar segment, and the value displayed will be the length of that segment. (useful for stacked bars, i.e., Bar Label Demo)
paddingfloat, default: 0
Distance of label from the end of the bar, in points. **kwargs
Any remaining keyword arguments are passed through to Axes.annotate. Returns
list of Text
A list of Text instances for the labels.
Examples using matplotlib.axes.Axes.bar_label
Bar Label Demo
Grouped bar chart with labels | matplotlib._as_gen.matplotlib.axes.axes.bar_label |
matplotlib.axes.Axes.barbs Axes.barbs(*args, data=None, **kwargs)[source]
Plot a 2D field of barbs. Call signature: barbs([X, Y], U, V, [C], **kw)
Where X, Y define the barb locations, U, V define the barb directions, and C optionally sets the color. All arguments may be 1D or 2D. U, V, C may be masked arrays, but masked X, Y are not supported at present. Barbs are traditionally used in meteorology as a way to plot the speed and direction of wind observations, but can technically be used to plot any two dimensional vector quantity. As opposed to arrows, which give vector magnitude by the length of the arrow, the barbs give more quantitative information about the vector magnitude by putting slanted lines or a triangle for various increments in magnitude, as show schematically below: : /\ \
: / \ \
: / \ \ \
: / \ \ \
: ------------------------------
The largest increment is given by a triangle (or "flag"). After those come full lines (barbs). The smallest increment is a half line. There is only, of course, ever at most 1 half line. If the magnitude is small and only needs a single half-line and no full lines or triangles, the half-line is offset from the end of the barb so that it can be easily distinguished from barbs with a single full line. The magnitude for the barb shown above would nominally be 65, using the standard increments of 50, 10, and 5. See also https://en.wikipedia.org/wiki/Wind_barb. Parameters
X, Y1D or 2D array-like, optional
The x and y coordinates of the barb locations. See pivot for how the barbs are drawn to the x, y positions. If not given, they will be generated as a uniform integer meshgrid based on the dimensions of U and V. If X and Y are 1D but U, V are 2D, X, Y are expanded to 2D using X, Y = np.meshgrid(X, Y). In this case len(X) and len(Y) must match the column and row dimensions of U and V.
U, V1D or 2D array-like
The x and y components of the barb shaft.
C1D or 2D array-like, optional
Numeric data that defines the barb colors by colormapping via norm and cmap. This does not support explicit colors. If you want to set colors directly, use barbcolor instead.
lengthfloat, default: 7
Length of the barb in points; the other parts of the barb are scaled against this.
pivot{'tip', 'middle'} or float, default: 'tip'
The part of the arrow that is anchored to the X, Y grid. The barb rotates about this point. This can also be a number, which shifts the start of the barb that many points away from grid point.
barbcolorcolor or color sequence
The color of all parts of the barb except for the flags. This parameter is analogous to the edgecolor parameter for polygons, which can be used instead. However this parameter will override facecolor.
flagcolorcolor or color sequence
The color of any flags on the barb. This parameter is analogous to the facecolor parameter for polygons, which can be used instead. However, this parameter will override facecolor. If this is not set (and C has not either) then flagcolor will be set to match barbcolor so that the barb has a uniform color. If C has been set, flagcolor has no effect.
sizesdict, optional
A dictionary of coefficients specifying the ratio of a given feature to the length of the barb. Only those values one wishes to override need to be included. These features include: 'spacing' - space between features (flags, full/half barbs) 'height' - height (distance from shaft to top) of a flag or full barb 'width' - width of a flag, twice the width of a full barb 'emptybarb' - radius of the circle used for low magnitudes
fill_emptybool, default: False
Whether the empty barbs (circles) that are drawn should be filled with the flag color. If they are not filled, the center is transparent.
roundingbool, default: True
Whether the vector magnitude should be rounded when allocating barb components. If True, the magnitude is rounded to the nearest multiple of the half-barb increment. If False, the magnitude is simply truncated to the next lowest multiple.
barb_incrementsdict, optional
A dictionary of increments specifying values to associate with different parts of the barb. Only those values one wishes to override need to be included. 'half' - half barbs (Default is 5) 'full' - full barbs (Default is 10) 'flag' - flags (default is 50)
flip_barbbool or array-like of bool, default: False
Whether the lines and flags should point opposite to normal. Normal behavior is for the barbs and lines to point right (comes from wind barbs having these features point towards low pressure in the Northern Hemisphere). A single value is applied to all barbs. Individual barbs can be flipped by passing a bool array of the same size as U and V. Returns
barbsBarbs
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). **kwargs
The barbs can further be customized using PolyCollection keyword arguments:
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
Examples using matplotlib.axes.Axes.barbs
Wind Barbs
barbs(X, Y, U, V) | matplotlib._as_gen.matplotlib.axes.axes.barbs |
matplotlib.axes.Axes.barh Axes.barh(y, width, height=0.8, left=None, *, align='center', **kwargs)[source]
Make a horizontal bar plot. The bars are positioned at y with the given alignment. Their dimensions are given by width and height. The horizontal baseline is left (default 0). Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar. Parameters
yfloat or array-like
The y coordinates of the bars. See also align for the alignment of the bars to the coordinates.
widthfloat or array-like
The width(s) of the bars.
heightfloat or array-like, default: 0.8
The heights of the bars.
leftfloat or array-like, default: 0
The x coordinates of the left sides of the bars.
align{'center', 'edge'}, default: 'center'
Alignment of the base to the y coordinates*: 'center': Center the bars on the y positions. 'edge': Align the bottom edges of the bars with the y positions. To align the bars on the top edge pass a negative height and align='edge'. Returns
BarContainer
Container with all the bars and optionally errorbars. Other Parameters
colorcolor or list of color, optional
The colors of the bar faces.
edgecolorcolor or list of color, optional
The colors of the bar edges.
linewidthfloat or array-like, optional
Width of the bar edge(s). If 0, don't draw edges.
tick_labelstr or list of str, optional
The tick labels of the bars. Default: None (Use default numeric labels.)
xerr, yerrfloat or array-like of shape(N,) or shape(2, N), optional
If not None, add horizontal / vertical errorbars to the bar tips. The values are +/- sizes relative to the data: scalar: symmetric +/- values for all bars shape(N,): symmetric +/- values for each bar 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. (default) See Different ways of specifying error bars for an example on the usage of xerr and yerr.
ecolorcolor or list of color, default: 'black'
The line color of the errorbars.
capsizefloat, default: rcParams["errorbar.capsize"] (default: 0.0)
The length of the error bar caps in points.
error_kwdict, optional
Dictionary of kwargs to be passed to the errorbar method. Values of ecolor or capsize defined here take precedence over the independent kwargs.
logbool, default: False
If True, set the x-axis to be log scale.
**kwargsRectangle 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
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 See also bar
Plot a vertical bar plot. Notes Stacked bars can be achieved by passing individual left values per bar. See Discrete distribution as horizontal bar chart .
Examples using matplotlib.axes.Axes.barh
Bar Label Demo
Horizontal bar chart
Producing multiple histograms side by side
The Lifecycle of a Plot | matplotlib._as_gen.matplotlib.axes.axes.barh |
matplotlib.axes.Axes.boxplot Axes.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_ticks=True, autorange=False, zorder=None, *, data=None)[source]
Draw a box and whisker plot. The box extends from the first quartile (Q1) to the third quartile (Q3) of the data, with a line at the median. The whiskers extend from the box by 1.5x the inter-quartile range (IQR). Flier points are those past the end of the whiskers. See https://en.wikipedia.org/wiki/Box_plot for reference. Q1-1.5IQR Q1 median Q3 Q3+1.5IQR
|-----:-----|
o |--------| : |--------| o o
|-----:-----|
flier <-----------> fliers
IQR
Parameters
xArray or a sequence of vectors.
The input data. If a 2D array, a boxplot is drawn for each column in x. If a sequence of 1D arrays, a boxplot is drawn for each array in x.
notchbool, default: False
Whether to draw a notched boxplot (True), or a rectangular boxplot (False). The notches represent the confidence interval (CI) around the median. The documentation for bootstrap describes how the locations of the notches are computed by default, but their locations may also be overridden by setting the conf_intervals parameter. Note In cases where the values of the CI are less than the lower quartile or greater than the upper quartile, the notches will extend beyond the box, giving it a distinctive "flipped" appearance. This is expected behavior and consistent with other statistical visualization packages.
symstr, optional
The default symbol for flier points. An empty string ('') hides the fliers. If None, then the fliers default to 'b+'. More control is provided by the flierprops parameter.
vertbool, default: True
If True, draws vertical boxes. If False, draw horizontal boxes.
whisfloat or (float, float), default: 1.5
The position of the whiskers. If a float, the lower whisker is at the lowest datum above Q1 - whis*(Q3-Q1), and the upper whisker at the highest datum below Q3 + whis*(Q3-Q1), where Q1 and Q3 are the first and third quartiles. The default value of whis = 1.5 corresponds to Tukey's original definition of boxplots. If a pair of floats, they indicate the percentiles at which to draw the whiskers (e.g., (5, 95)). In particular, setting this to (0, 100) results in whiskers covering the whole range of the data. In the edge case where Q1 == Q3, whis is automatically set to (0, 100) (cover the whole range of the data) if autorange is True. Beyond the whiskers, data are considered outliers and are plotted as individual points.
bootstrapint, optional
Specifies whether to bootstrap the confidence intervals around the median for notched boxplots. If bootstrap is None, no bootstrapping is performed, and notches are calculated using a Gaussian-based asymptotic approximation (see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and Kendall and Stuart, 1967). Otherwise, bootstrap specifies the number of times to bootstrap the median to determine its 95% confidence intervals. Values between 1000 and 10000 are recommended.
usermedians1D array-like, optional
A 1D array-like of length len(x). Each entry that is not None forces the value of the median for the corresponding dataset. For entries that are None, the medians are computed by Matplotlib as normal.
conf_intervalsarray-like, optional
A 2D array-like of shape (len(x), 2). Each entry that is not None forces the location of the corresponding notch (which is only drawn if notch is True). For entries that are None, the notches are computed by the method specified by the other parameters (e.g., bootstrap).
positionsarray-like, optional
The positions of the boxes. The ticks and limits are automatically set to match the positions. Defaults to range(1, N+1) where N is the number of boxes to be drawn.
widthsfloat or array-like
The widths of the boxes. The default is 0.5, or 0.15*(distance
between extreme positions), if that is smaller.
patch_artistbool, default: False
If False produces boxes with the Line2D artist. Otherwise, boxes are drawn with Patch artists.
labelssequence, optional
Labels for each dataset (one per dataset).
manage_ticksbool, default: True
If True, the tick locations and labels will be adjusted to match the boxplot positions.
autorangebool, default: False
When True and the data are distributed such that the 25th and 75th percentiles are equal, whis is set to (0, 100) such that the whisker ends are at the minimum and maximum of the data.
meanlinebool, default: False
If True (and showmeans is True), will try to render the mean as a line spanning the full width of the box according to meanprops (see below). Not recommended if shownotches is also True. Otherwise, means will be shown as points.
zorderfloat, default: Line2D.zorder = 2
The zorder of the boxplot. Returns
dict
A dictionary mapping each component of the boxplot to a list of the Line2D instances created. That dictionary has the following keys (assuming vertical boxplots):
boxes: the main body of the boxplot showing the quartiles and the median's confidence intervals if enabled.
medians: horizontal lines at the median of each box.
whiskers: the vertical lines extending to the most extreme, non-outlier data points.
caps: the horizontal lines at the ends of the whiskers.
fliers: points representing data that extend beyond the whiskers (fliers).
means: points or lines representing the means. Other Parameters
showcapsbool, default: True
Show the caps on the ends of whiskers.
showboxbool, default: True
Show the central box.
showfliersbool, default: True
Show the outliers beyond the caps.
showmeansbool, default: False
Show the arithmetic means.
cappropsdict, default: None
The style of the caps.
boxpropsdict, default: None
The style of the box.
whiskerpropsdict, default: None
The style of the whiskers.
flierpropsdict, default: None
The style of the fliers.
medianpropsdict, default: None
The style of the median.
meanpropsdict, default: None
The style of the mean.
dataindexable object, optional
If given, all parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception). See also violinplot
Draw an estimate of the probability density function.
Examples using matplotlib.axes.Axes.boxplot
Box plots with custom fill colors
Boxplots
Boxplot Demo
boxplot(X) | matplotlib._as_gen.matplotlib.axes.axes.boxplot |
matplotlib.axes.Axes.broken_barh Axes.broken_barh(xranges, yrange, *, data=None, **kwargs)[source]
Plot a horizontal sequence of rectangles. A rectangle is drawn for each element of xranges. All rectangles have the same vertical position and size defined by yrange. This is a convenience function for instantiating a BrokenBarHCollection, adding it to the Axes and autoscaling the view. Parameters
xrangessequence of tuples (xmin, xwidth)
The x-positions and extends of the rectangles. For each tuple (xmin, xwidth) a rectangle is drawn from xmin to xmin + xwidth.
yrange(ymin, yheight)
The y-position and extend for all the rectangles. Returns
BrokenBarHCollection
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).
**kwargsBrokenBarHCollection properties
Each kwarg can be either a single argument applying to all rectangles, e.g.: facecolors='black'
or a sequence of arguments over which is cycled, e.g.: facecolors=('black', 'blue')
would create interleaving black and blue rectangles. Supported keywords:
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
Examples using matplotlib.axes.Axes.broken_barh
Broken Barh | matplotlib._as_gen.matplotlib.axes.axes.broken_barh |
matplotlib.axes.Axes.bxp Axes.bxp(bxpstats, positions=None, widths=None, vert=True, patch_artist=False, shownotches=False, showmeans=False, showcaps=True, showbox=True, showfliers=True, boxprops=None, whiskerprops=None, flierprops=None, medianprops=None, capprops=None, meanprops=None, meanline=False, manage_ticks=True, zorder=None)[source]
Drawing function for box and whisker plots. Make a box and whisker plot for each column of x or each vector in sequence x. The box extends from the lower to upper quartile values of the data, with a line at the median. The whiskers extend from the box to show the range of the data. Flier points are those past the end of the whiskers. Parameters
bxpstatslist of dicts
A list of dictionaries containing stats for each boxplot. Required keys are:
med: Median (scalar).
q1, q3: First & third quartiles (scalars).
whislo, whishi: Lower & upper whisker positions (scalars). Optional keys are:
mean: Mean (scalar). Needed if showmeans=True.
fliers: Data beyond the whiskers (array-like). Needed if showfliers=True.
cilo, cihi: Lower & upper confidence intervals about the median. Needed if shownotches=True.
label: Name of the dataset (str). If available, this will be used a tick label for the boxplot
positionsarray-like, default: [1, 2, ..., n]
The positions of the boxes. The ticks and limits are automatically set to match the positions.
widthsfloat or array-like, default: None
The widths of the boxes. The default is clip(0.15*(distance between extreme positions), 0.15, 0.5).
vertbool, default: True
If True (default), makes the boxes vertical. If False, makes horizontal boxes.
patch_artistbool, default: False
If False produces boxes with the Line2D artist. If True produces boxes with the Patch artist.
shownotches, showmeans, showcaps, showbox, showfliersbool
Whether to draw the CI notches, the mean value (both default to False), the caps, the box, and the fliers (all three default to True).
boxprops, whiskerprops, capprops, flierprops, medianprops, meanpropsdict, optional
Artist properties for the boxes, whiskers, caps, fliers, medians, and means.
meanlinebool, default: False
If True (and showmeans is True), will try to render the mean as a line spanning the full width of the box according to meanprops. Not recommended if shownotches is also True. Otherwise, means will be shown as points.
manage_ticksbool, default: True
If True, the tick locations and labels will be adjusted to match the boxplot positions.
zorderfloat, default: Line2D.zorder = 2
The zorder of the resulting boxplot. Returns
dict
A dictionary mapping each component of the boxplot to a list of the Line2D instances created. That dictionary has the following keys (assuming vertical boxplots):
boxes: main bodies of the boxplot showing the quartiles, and the median's confidence intervals if enabled.
medians: horizontal lines at the median of each box.
whiskers: vertical lines up to the last non-outlier data.
caps: horizontal lines at the ends of the whiskers.
fliers: points representing data beyond the whiskers (fliers).
means: points or lines representing the means. Examples (Source code, png, pdf) (png, pdf) | matplotlib._as_gen.matplotlib.axes.axes.bxp |
matplotlib.axes.Axes.can_pan Axes.can_pan()[source]
Return whether this Axes supports any pan/zoom button functionality. | matplotlib._as_gen.matplotlib.axes.axes.can_pan |
matplotlib.axes.Axes.can_zoom Axes.can_zoom()[source]
Return whether this Axes supports the zoom box button functionality. | matplotlib._as_gen.matplotlib.axes.axes.can_zoom |
matplotlib.axes.Axes.cla Axes.cla()[source]
Clear the Axes.
Examples using matplotlib.axes.Axes.cla
pyplot animation
Data Browser | matplotlib._as_gen.matplotlib.axes.axes.cla |
matplotlib.axes.Axes.clabel Axes.clabel(CS, levels=None, **kwargs)[source]
Label a contour plot. Adds labels to line contours in given ContourSet. Parameters
CSContourSet instance
Line contours to label.
levelsarray-like, optional
A list of level values, that should be labeled. The list must be a subset of CS.levels. If not given, all levels are labeled. **kwargs
All other parameters are documented in clabel.
Examples using matplotlib.axes.Axes.clabel
Contour Demo
Contour Label Demo
Contourf Demo
Contouring the solution space of optimizations
Patheffect Demo
TickedStroke patheffect | matplotlib._as_gen.matplotlib.axes.axes.clabel |
matplotlib.axes.Axes.clear Axes.clear()[source]
Clear the Axes. | matplotlib._as_gen.matplotlib.axes.axes.clear |
matplotlib.axes.Axes.cohere Axes.cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, *, data=None, **kwargs)[source]
Plot the coherence between x and y. Plot the coherence between x and y. Coherence is the normalized cross spectral density: \[C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}\] Parameters
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 blocks.
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. Returns
Cxy1-D array
The coherence vector.
freqs1-D array
The frequencies for the elements in Cxy. 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 References Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986) | matplotlib._as_gen.matplotlib.axes.axes.cohere |
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._as_gen.matplotlib.axes.axes.contains |
matplotlib.axes.Axes.contains_point Axes.contains_point(point)[source]
Return whether point (pair of pixel coordinates) is inside the axes patch. | matplotlib._as_gen.matplotlib.axes.axes.contains_point |
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._as_gen.matplotlib.axes.axes.contour |
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._as_gen.matplotlib.axes.axes.contourf |
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._as_gen.matplotlib.axes.axes.convert_xunits |
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._as_gen.matplotlib.axes.axes.convert_yunits |
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._as_gen.matplotlib.axes.axes.csd |
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._as_gen.matplotlib.axes.axes.drag_pan |
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._as_gen.matplotlib.axes.axes.draw |
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._as_gen.matplotlib.axes.axes.draw_artist |
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._as_gen.matplotlib.axes.axes.end_pan |
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._as_gen.matplotlib.axes.axes.errorbar |
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._as_gen.matplotlib.axes.axes.eventplot |
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._as_gen.matplotlib.axes.axes.fill |
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._as_gen.matplotlib.axes.axes.fill_between |
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._as_gen.matplotlib.axes.axes.fill_betweenx |
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._as_gen.matplotlib.axes.axes.findobj |
matplotlib.axes.Axes.format_coord Axes.format_coord(x, y)[source]
Return a format string formatting the x, y coordinates. | matplotlib._as_gen.matplotlib.axes.axes.format_coord |
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._as_gen.matplotlib.axes.axes.format_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._as_gen.matplotlib.axes.axes.format_xdata |
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._as_gen.matplotlib.axes.axes.format_ydata |
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._as_gen.matplotlib.axes.axes.get_adjustable |
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._as_gen.matplotlib.axes.axes.get_anchor |
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._as_gen.matplotlib.axes.axes.get_aspect |
matplotlib.axes.Axes.get_autoscale_on Axes.get_autoscale_on()[source]
Return True if each axis is autoscaled, False otherwise. | matplotlib._as_gen.matplotlib.axes.axes.get_autoscale_on |
matplotlib.axes.Axes.get_autoscalex_on Axes.get_autoscalex_on()[source]
Return whether the x-axis is autoscaled. | matplotlib._as_gen.matplotlib.axes.axes.get_autoscalex_on |
matplotlib.axes.Axes.get_autoscaley_on Axes.get_autoscaley_on()[source]
Return whether the y-axis is autoscaled. | matplotlib._as_gen.matplotlib.axes.axes.get_autoscaley_on |
matplotlib.axes.Axes.get_axes_locator Axes.get_axes_locator()[source]
Return the axes_locator. | matplotlib._as_gen.matplotlib.axes.axes.get_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._as_gen.matplotlib.axes.axes.get_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._as_gen.matplotlib.axes.axes.get_box_aspect |
matplotlib.axes.Axes.get_children Axes.get_children()[source]
Return a list of the child Artists of this Artist. | matplotlib._as_gen.matplotlib.axes.axes.get_children |
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._as_gen.matplotlib.axes.axes.get_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._as_gen.matplotlib.axes.axes.get_data_ratio |
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._as_gen.matplotlib.axes.axes.get_default_bbox_extra_artists |
matplotlib.axes.Axes.get_facecolor Axes.get_facecolor()[source]
Get the facecolor of the Axes. | matplotlib._as_gen.matplotlib.axes.axes.get_facecolor |
matplotlib.axes.Axes.get_frame_on Axes.get_frame_on()[source]
Get whether the Axes rectangle patch is drawn. | matplotlib._as_gen.matplotlib.axes.axes.get_frame_on |
matplotlib.axes.Axes.get_images Axes.get_images()[source]
Return a list of AxesImages contained by the Axes. | matplotlib._as_gen.matplotlib.axes.axes.get_images |
matplotlib.axes.Axes.get_legend Axes.get_legend()[source]
Return the Legend instance, or None if no legend is defined. | matplotlib._as_gen.matplotlib.axes.axes.get_legend |
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._as_gen.matplotlib.axes.axes.get_legend_handles_labels |
matplotlib.axes.Axes.get_lines Axes.get_lines()[source]
Return a list of lines contained by the Axes. | matplotlib._as_gen.matplotlib.axes.axes.get_lines |
matplotlib.axes.Axes.get_navigate Axes.get_navigate()[source]
Get whether the Axes responds to navigation commands. | matplotlib._as_gen.matplotlib.axes.axes.get_navigate |
matplotlib.axes.Axes.get_navigate_mode Axes.get_navigate_mode()[source]
Get the navigation toolbar button status: 'PAN', 'ZOOM', or None. | matplotlib._as_gen.matplotlib.axes.axes.get_navigate_mode |
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._as_gen.matplotlib.axes.axes.get_position |
matplotlib.axes.Axes.get_rasterization_zorder Axes.get_rasterization_zorder()[source]
Return the zorder value below which artists will be rasterized. | matplotlib._as_gen.matplotlib.axes.axes.get_rasterization_zorder |
matplotlib.axes.Axes.get_renderer_cache Axes.get_renderer_cache()[source] | matplotlib._as_gen.matplotlib.axes.axes.get_renderer_cache |
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._as_gen.matplotlib.axes.axes.get_shared_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._as_gen.matplotlib.axes.axes.get_shared_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._as_gen.matplotlib.axes.axes.get_tightbbox |
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._as_gen.matplotlib.axes.axes.get_title |
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._as_gen.matplotlib.axes.axes.get_transformed_clip_path_and_affine |
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._as_gen.matplotlib.axes.axes.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._as_gen.matplotlib.axes.axes.get_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._as_gen.matplotlib.axes.axes.get_xaxis_text1_transform |
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._as_gen.matplotlib.axes.axes.get_xaxis_text2_transform |
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._as_gen.matplotlib.axes.axes.get_xaxis_transform |
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._as_gen.matplotlib.axes.axes.get_xbound |
matplotlib.axes.Axes.get_xgridlines Axes.get_xgridlines()[source]
Return the xaxis' grid lines as a list of Line2Ds. | matplotlib._as_gen.matplotlib.axes.axes.get_xgridlines |
matplotlib.axes.Axes.get_xlabel Axes.get_xlabel()[source]
Get the xlabel text string. | matplotlib._as_gen.matplotlib.axes.axes.get_xlabel |
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._as_gen.matplotlib.axes.axes.get_xlim |
matplotlib.axes.Axes.get_xmajorticklabels Axes.get_xmajorticklabels()[source]
Return the xaxis' major tick labels, as a list of Text. | matplotlib._as_gen.matplotlib.axes.axes.get_xmajorticklabels |
matplotlib.axes.Axes.get_xminorticklabels Axes.get_xminorticklabels()[source]
Return the xaxis' minor tick labels, as a list of Text. | matplotlib._as_gen.matplotlib.axes.axes.get_xminorticklabels |
matplotlib.axes.Axes.get_xscale Axes.get_xscale()[source]
Return the xaxis' scale (as a str). | matplotlib._as_gen.matplotlib.axes.axes.get_xscale |
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._as_gen.matplotlib.axes.axes.get_xticklabels |
matplotlib.axes.Axes.get_xticklines Axes.get_xticklines(minor=False)[source]
Return the xaxis' tick lines as a list of Line2Ds. | matplotlib._as_gen.matplotlib.axes.axes.get_xticklines |
matplotlib.axes.Axes.get_xticks Axes.get_xticks(*, minor=False)[source]
Return the xaxis' tick locations in data coordinates. | matplotlib._as_gen.matplotlib.axes.axes.get_xticks |
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._as_gen.matplotlib.axes.axes.get_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._as_gen.matplotlib.axes.axes.get_yaxis_text1_transform |
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._as_gen.matplotlib.axes.axes.get_yaxis_text2_transform |
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._as_gen.matplotlib.axes.axes.get_yaxis_transform |
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._as_gen.matplotlib.axes.axes.get_ybound |
matplotlib.axes.Axes.get_ygridlines Axes.get_ygridlines()[source]
Return the yaxis' grid lines as a list of Line2Ds. | matplotlib._as_gen.matplotlib.axes.axes.get_ygridlines |
matplotlib.axes.Axes.get_ylabel Axes.get_ylabel()[source]
Get the ylabel text string. | matplotlib._as_gen.matplotlib.axes.axes.get_ylabel |
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._as_gen.matplotlib.axes.axes.get_ylim |
matplotlib.axes.Axes.get_ymajorticklabels Axes.get_ymajorticklabels()[source]
Return the yaxis' major tick labels, as a list of Text. | matplotlib._as_gen.matplotlib.axes.axes.get_ymajorticklabels |
matplotlib.axes.Axes.get_yminorticklabels Axes.get_yminorticklabels()[source]
Return the yaxis' minor tick labels, as a list of Text. | matplotlib._as_gen.matplotlib.axes.axes.get_yminorticklabels |
matplotlib.axes.Axes.get_yscale Axes.get_yscale()[source]
Return the yaxis' scale (as a str). | matplotlib._as_gen.matplotlib.axes.axes.get_yscale |
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._as_gen.matplotlib.axes.axes.get_yticklabels |
matplotlib.axes.Axes.get_yticklines Axes.get_yticklines(minor=False)[source]
Return the yaxis' tick lines as a list of Line2Ds. | matplotlib._as_gen.matplotlib.axes.axes.get_yticklines |
matplotlib.axes.Axes.get_yticks Axes.get_yticks(*, minor=False)[source]
Return the yaxis' tick locations in data coordinates. | matplotlib._as_gen.matplotlib.axes.axes.get_yticks |
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._as_gen.matplotlib.axes.axes.grid |
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._as_gen.matplotlib.axes.axes.has_data |
matplotlib.axes.Axes.have_units Axes.have_units()[source]
Return whether units are set on any axis. | matplotlib._as_gen.matplotlib.axes.axes.have_units |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.