GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing matplotlib.org (truncated) — pyplot — Matplotlib 2.0.2 documentation You are reading an old version of the documentation (v2.0.2). For the latest version see https://matplotlib.org/stable/
NavigationTravis-CI: Table Of ContentsRelated Topics
This PageQuick searchpyplot¶
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters: | x : sequence of scalar hold : boolean, optional, deprecated, default: True detrend : callable, optional, default:
normed : boolean, optional, default: True
usevlines : boolean, optional, default: True
maxlags : integer, optional, default: 10
|
|---|---|
| Returns: | (lags, c, line, b) : where: |
| Other Parameters: | |
linestyle :
marker : string, optional, default: ‘o’ |
|
Notes
The cross correlation is performed with numpy.correlate() with
mode = 2.
Examples
xcorr is top graph, and
acorr is bottom graph.
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, hold=None, data=None, **kwargs)¶Plot the angle spectrum.
Call signature:
angle_spectrum(x, Fs=2, Fc=0, window=mlab.window_hanning, pad_to=None, sides='default', **kwargs)
Compute the angle spectrum (wrapped phase spectrum) of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.
| Parameters: | x : 1-D array or sequence
Fs : scalar
window : callable or ndarray
sides : [ ‘default’ | ‘onesided’ | ‘twosided’ ]
pad_to : integer
Fc : integer
**kwargs :
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | spectrum : 1-D array
freqs : 1-D array
line : a
|
See also
magnitude_spectrum()angle_spectrum() plots the magnitudes of the corresponding frequencies.phase_spectrum()phase_spectrum() plots the unwrapped version of this function.specgram()specgram() can plot the angle spectrum of segments within the signal in a colormap.Examples
(Source code, png, pdf)
matplotlib.pyplot.annotate(*args, **kwargs)¶Annotate the point xy with text s.
Additional kwargs are passed to Text.
| Parameters: | s : str
xy : iterable
xytext : iterable, optional
xycoords : str, Artist, Transform, callable or tuple, optional
textcoords : str,
arrowprops : dict, optional
annotation_clip : bool, optional
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | Annotation |
matplotlib.pyplot.arrow(x, y, dx, dy, hold=None, **kwargs)¶Add an arrow to the axes.
Draws arrow on specified axis from (x, y) to (x + dx,
y + dy). Uses FancyArrow patch to construct the arrow.
| Parameters: | x : float
y : float
dx : float
dy : float
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | a : FancyArrow
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Other Parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional kwargs (inherited from FancyArrow patch) control the arrow construction and properties: Constructor arguments
Other valid kwargs (inherited from :class:`Patch`) are:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Notes
The resulting arrow is affected by the axes aspect ratio and limits.
This may produce an arrow whose head is not square with its stem. To
create an arrow whose head is square with its stem, use
annotate() for example:
ax.annotate("", xy=(0.5, 0.5), xytext=(0, 0), arrowprops=dict(arrowstyle="->"))
Examples
(Source code, png, pdf)
matplotlib.pyplot.autoscale(enable=True, axis='both', tight=None)¶Autoscale the axis view to the data (toggle).
Convenience method for simple axis view autoscaling. It turns autoscaling on or off, and then, if autoscaling for either axis is on, it performs the autoscaling on the specified axis or axes.
Returns None.
matplotlib.pyplot.autumn()¶set the default colormap to autumn and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.axes(*args, **kwargs)¶Add an axes to the figure.
The axes is added at position rect specified by:
axes() by itself creates a default full subplot(111) window axis.axes(rect, facecolor='w') where rect = [left, bottom, width,
height] in normalized (0, 1) units. facecolor is the background
color for the axis, default white.axes(h) where h is an axes instance makes h the current
axis. An Axes instance is returned.| kwarg | Accepts | Description |
|---|---|---|
| facecolor | color | the axes background color |
| frameon | [True|False] | display the frame? |
| sharex | otherax | current axes shares xaxis attribute with otherax |
| sharey | otherax | current axes shares yaxis attribute with otherax |
| polar | [True|False] | use a polar axes? |
| aspect | [str | num] | [‘equal’, ‘auto’] or a number. If a number
the ratio of x-unit/y-unit in screen-space.
Also see
set_aspect(). |
Examples:
examples/pylab_examples/axes_demo.py places custom axes.examples/pylab_examples/shared_axis_demo.py uses
sharex and sharey.matplotlib.pyplot.axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs)¶Add a horizontal line across the axis.
| Parameters: | y : scalar, optional, default: 0
xmin : scalar, optional, default: 0
xmax : scalar, optional, default: 1
|
|---|---|
| Returns: |
See also
axhspanNotes
kwargs are passed to Line2D and can be used
to control the line properties.
Examples
draw a thick red hline at ‘y’ = 0 that spans the xrange:
>>> axhline(linewidth=4, color='r')
draw a default hline at ‘y’ = 1 that spans the xrange:
>>> axhline(y=1)
draw a default hline at ‘y’ = .5 that spans the middle half of the xrange:
>>> axhline(y=.5, xmin=0.25, xmax=0.75)
Valid kwargs are Line2D properties,
with the exception of ‘transform’:
Property Description agg_filterunknown alphafloat (0.0 transparent through 1.0 opaque) animated[True | False] antialiasedor aa[True | False] axesan Axesinstanceclip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]coloror cany matplotlib color containsa callable function dash_capstyle[‘butt’ | ‘round’ | ‘projecting’] dash_joinstyle[‘miter’ | ‘round’ | ‘bevel’] dashessequence of on/off ink in points drawstyle[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’] figurea matplotlib.figure.Figureinstancefillstyle[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’] gidan id string labelstring or anything printable with ‘%s’ conversion. linestyleor ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor lwfloat value in points markerA valid marker stylemarkeredgecoloror mecany matplotlib color markeredgewidthor mewfloat value in points markerfacecoloror mfcany matplotlib color markerfacecoloraltor mfcaltany matplotlib color markersizeor msfloat markevery[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] path_effectsunknown pickerfloat distance in points or callable pick function fn(artist, event)pickradiusfloat distance in points rasterized[True | False | None] sketch_paramsunknown snapunknown solid_capstyle[‘butt’ | ‘round’ | ‘projecting’] solid_joinstyle[‘miter’ | ‘round’ | ‘bevel’] transforma matplotlib.transforms.Transforminstanceurla url string visible[True | False] xdata1D array ydata1D array zorderany number
matplotlib.pyplot.axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs)¶Add a horizontal span (rectangle) across the axis.
Draw a horizontal span (rectangle) from ymin to ymax.
With the default values of xmin = 0 and xmax = 1, this
always spans the xrange, regardless of the xlim settings, even
if you change them, e.g., with the set_xlim() command.
That is, the horizontal extent is in axes coords: 0=left,
0.5=middle, 1.0=right but the y location is in data
coordinates.
| Parameters: | ymin : float
ymax : float
xmin : float, optional, default: 0
xmax : float, optional, default: 1
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | Polygon : |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Other Parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kwargs :
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
See also
axvspanExamples
(Source code, png, pdf)
matplotlib.pyplot.axis(*v, **kwargs)¶Convenience method to get or set axis properties.
Calling with no arguments:
>>> axis()
returns the current axes limits [xmin, xmax, ymin, ymax].:
>>> axis(v)
sets the min and max of the x and y axes, with
v = [xmin, xmax, ymin, ymax].:
>>> axis('off')
turns off the axis lines and labels.:
>>> axis('equal')
changes limits of x or y axis so that equal increments of x and y have the same length; a circle is circular.:
>>> axis('scaled')
achieves the same result by changing the dimensions of the plot box instead of the axis data limits.:
>>> axis('tight')
changes x and y axis limits such that all data is shown. If all data is already shown, it will move it to the center of the figure without modifying (xmax - xmin) or (ymax - ymin). Note this is slightly different than in MATLAB.:
>>> axis('image')
is ‘scaled’ with the axis limits equal to the data limits.:
>>> axis('auto')
and:
>>> axis('normal')
are deprecated. They restore default behavior; axis limits are automatically scaled to make the data fit comfortably within the plot box.
if len(*v)==0, you can pass in xmin, xmax, ymin, ymax
as kwargs selectively to alter just those limits without changing
the others.
>>> axis('square')
changes the limit ranges (xmax-xmin) and (ymax-ymin) of the x and y axes to be the same, and have the same scaling, resulting in a square plot.
The xmin, xmax, ymin, ymax tuple is returned
matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs)¶Add a vertical line across the axes.
| Parameters: | x : scalar, optional, default: 0
ymin : scalar, optional, default: 0
ymax : scalar, optional, default: 1
|
|---|---|
| Returns: |
See also
axhspanExamples
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)
Valid kwargs are Line2D properties,
with the exception of ‘transform’:
Property Description agg_filterunknown alphafloat (0.0 transparent through 1.0 opaque) animated[True | False] antialiasedor aa[True | False] axesan Axesinstanceclip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]coloror cany matplotlib color containsa callable function dash_capstyle[‘butt’ | ‘round’ | ‘projecting’] dash_joinstyle[‘miter’ | ‘round’ | ‘bevel’] dashessequence of on/off ink in points drawstyle[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’] figurea matplotlib.figure.Figureinstancefillstyle[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’] gidan id string labelstring or anything printable with ‘%s’ conversion. linestyleor ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor lwfloat value in points markerA valid marker stylemarkeredgecoloror mecany matplotlib color markeredgewidthor mewfloat value in points markerfacecoloror mfcany matplotlib color markerfacecoloraltor mfcaltany matplotlib color markersizeor msfloat markevery[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] path_effectsunknown pickerfloat distance in points or callable pick function fn(artist, event)pickradiusfloat distance in points rasterized[True | False | None] sketch_paramsunknown snapunknown solid_capstyle[‘butt’ | ‘round’ | ‘projecting’] solid_joinstyle[‘miter’ | ‘round’ | ‘bevel’] transforma matplotlib.transforms.Transforminstanceurla url string visible[True | False] xdata1D array ydata1D array zorderany number
matplotlib.pyplot.axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs)¶Add a vertical span (rectangle) across the axes.
Draw a vertical span (rectangle) from xmin to xmax. With
the default values of ymin = 0 and ymax = 1. This always
spans the yrange, regardless of the ylim settings, even if you
change them, e.g., with the set_ylim() command. That is,
the vertical extent is in axes coords: 0=bottom, 0.5=middle,
1.0=top but the y location is in data coordinates.
| Parameters: | xmin : scalar
xmax : scalar
ymin : scalar, optional
ymax : scalar, optional
|
|---|---|
| Returns: | rectangle : matplotlib.patches.Polygon
|
| Other Parameters: | |
**kwargs
|
|
See also
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)
matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)¶Make a bar plot.
Make a bar plot with rectangles bounded by:
left,left+width,bottom,bottom+height- (left, right, bottom and top edges)
| Parameters: | left : sequence of scalars
height : sequence of scalars
width : scalar or array-like, optional
bottom : scalar or array-like, optional
color : scalar or array-like, optional
edgecolor : scalar or array-like, optional
linewidth : scalar or array-like, optional
tick_label : string or array-like, optional
xerr : scalar or array-like, optional
yerr : scalar or array-like, optional
ecolor : scalar or array-like, optional
capsize : scalar, optional
error_kw : dict, optional
align : {‘center’, ‘edge’}, optional
orientation : {‘vertical’, ‘horizontal’}, optional
log : boolean, optional
|
|---|---|
| Returns: | bars : matplotlib.container.BarContainer
|
See also
barhNotes
The optional arguments color, edgecolor, linewidth,
xerr, and yerr can be either scalars or sequences of
length equal to the number of bars. This enables you to use
bar as the basis for stacked bar charts, or candlestick plots.
Detail: xerr and yerr are passed directly to
errorbar(), so they can also have shape 2xN for
independent specification of lower and upper errors.
Other optional kwargs:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor aa[True | False] or None for default axesan Axesinstancecapstyle[‘butt’ | ‘round’ | ‘projecting’] clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]colormatplotlib color spec containsa callable function edgecoloror ecmpl color spec, None, ‘none’, or ‘auto’ facecoloror fcmpl color spec, or None for default, or ‘none’ for no color figurea matplotlib.figure.Figureinstancefill[True | False] gidan id string hatch[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’] joinstyle[‘miter’ | ‘round’ | ‘bevel’] labelstring or anything printable with ‘%s’ conversion. linestyleor ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor lwfloat or None for default path_effectsunknown picker[None|float|boolean|callable] rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string visible[True | False] zorderany number
Examples
Example: A stacked bar chart.
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.barbs(*args, **kw)¶Plot a 2-D field of barbs.
Call signatures:
barb(U, V, **kw) barb(U, V, C, **kw) barb(X, Y, U, V, **kw) barb(X, Y, U, V, C, **kw)
Arguments:
- X, Y:
- The x and y coordinates of the barb locations (default is head of barb; see pivot kwarg)
- U, V:
- Give the x and y components of the barb shaft
- C:
- An optional array used to map colors to the barbs
All arguments may be 1-D or 2-D arrays or sequences. If X and Y
are absent, they will be generated as a uniform grid. If U and V
are 2-D arrays but X and Y are 1-D, and if len(X) and len(Y)
match the column and row dimensions of U, then X and Y will be
expanded with numpy.meshgrid().
U, V, C may be masked arrays, but masked X, Y are not supported at present.
Keyword arguments:
- length:
- Length of the barb in points; the other parts of the barb are scaled against this. Default is 9
- pivot: [ ‘tip’ | ‘middle’ ]
- The part of the arrow that is at the grid point; the arrow rotates about this point, hence the name pivot. Default is ‘tip’
- barbcolor: [ color | color sequence ]
- Specifies the color all parts of the barb except any flags. This parameter is analagous to the edgecolor parameter for polygons, which can be used instead. However this parameter will override facecolor.
- flagcolor: [ color | color sequence ]
- Specifies the color of any flags on the barb. This parameter is analagous 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.
- sizes:
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_empty:
- A flag on whether the empty barbs (circles) that are drawn should be filled with the flag color. If they are not filled, they will be drawn such that no color is applied to the center. Default is False
- rounding:
- A flag to indicate 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. Default is True
- barb_increments:
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_barb:
- Either a single boolean flag or an array of booleans. Single boolean indicates whether the lines and flags should point opposite to normal for all barbs. An array (which should be the same size as the other data arrays) indicates whether to flip for each individual barb. 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.) Default is False
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.
linewidths and edgecolors can be used to customize the barb.
Additional PolyCollection keyword
arguments:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number
Example:
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.barh(bottom, width, height=0.8, left=None, hold=None, **kwargs)¶Make a horizontal bar plot.
Make a horizontal bar plot with rectangles bounded by:
left,left+width,bottom,bottom+height- (left, right, bottom and top edges)
bottom, width, height, and left can be either scalars
or sequences
| Parameters: | bottom : scalar or array-like
width : scalar or array-like
height : sequence of scalars, optional, default: 0.8
left : sequence of scalars
|
|---|---|
| Returns: |
|
| Other Parameters: | |
color : scalar or array-like, optional
edgecolor : scalar or array-like, optional
linewidth : scalar or array-like, optional, default: None
tick_label : string or array-like, optional, default: None
xerr : scalar or array-like, optional, default: None
yerr : scalar or array-like, optional, default: None
ecolor : scalar or array-like, optional, default: None
capsize : scalar, optional
error_kw :
align : {‘center’, ‘edge’}, optional
log : boolean, optional, default: False
|
|
See also
barNotes
The optional arguments color, edgecolor, linewidth,
xerr, and yerr can be either scalars or sequences of
length equal to the number of bars. This enables you to use
bar as the basis for stacked bar charts, or candlestick plots.
Detail: xerr and yerr are passed directly to
errorbar(), so they can also have shape 2xN for
independent specification of lower and upper errors.
Other optional kwargs:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor aa[True | False] or None for default axesan Axesinstancecapstyle[‘butt’ | ‘round’ | ‘projecting’] clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]colormatplotlib color spec containsa callable function edgecoloror ecmpl color spec, None, ‘none’, or ‘auto’ facecoloror fcmpl color spec, or None for default, or ‘none’ for no color figurea matplotlib.figure.Figureinstancefill[True | False] gidan id string hatch[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’] joinstyle[‘miter’ | ‘round’ | ‘bevel’] labelstring or anything printable with ‘%s’ conversion. linestyleor ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor lwfloat or None for default path_effectsunknown picker[None|float|boolean|callable] rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string visible[True | False] zorderany number
matplotlib.pyplot.bone()¶set the default colormap to bone and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.box(on=None)¶Turn the axes box on or off. on may be a boolean or a string, ‘on’ or ‘off’.
If on is None, toggle state.
matplotlib.pyplot.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_xticks=True, autorange=False, zorder=None, hold=None, data=None)¶Make a box and whisker plot.
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: | x : Array or a sequence of vectors.
notch : bool, optional (False)
sym : str, optional
vert : bool, optional (True)
whis : float, sequence, or string (default = 1.5)
bootstrap : int, optional
usermedians : array-like, optional
conf_intervals : array-like, optional
positions : array-like, optional
widths : scalar or array-like
patch_artist : bool, optional (False)
labels : sequence, optional
manage_xticks : bool, optional (True)
autorange : bool, optional (False)
meanline : bool, optional (False)
zorder : scalar, optional (None)
|
|---|---|
| Returns: | result : dict
|
| Other Parameters: | |
showcaps : bool, optional (True)
showbox : bool, optional (True)
showfliers : bool, optional (True)
showmeans : bool, optional (False)
capprops : dict, optional (None)
boxprops : dict, optional (None)
whiskerprops : dict, optional (None)
flierprops : dict, optional (None)
medianprops : dict, optional (None)
meanprops : dict, optional (None)
|
|
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.broken_barh(xranges, yrange, hold=None, data=None, **kwargs)¶Plot horizontal bars.
A collection of horizontal bars spanning yrange with a sequence of xranges.
Required arguments:
Argument Description xranges sequence of (xmin, xwidth) yrange sequence of (ymin, ywidth)
kwargs are
matplotlib.collections.BrokenBarHCollection
properties:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number
these can either be a single argument, i.e.,:
facecolors = 'black'
or a sequence of arguments for the various bars, i.e.,:
facecolors = ('black', 'red', 'green')
Example:
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.cla()¶Clear the current axes.
matplotlib.pyplot.clabel(CS, *args, **kwargs)¶Label a contour plot.
Call signature:
clabel(cs, **kwargs)
Adds labels to line contours in cs, where cs is a
ContourSet object returned by
contour.
clabel(cs, v, **kwargs)
only labels contours listed in v.
Optional keyword arguments:
- fontsize:
- size in points or relative size e.g., ‘smaller’, ‘x-large’
- colors:
- if None, the color of each label matches the color of the corresponding contour
- if one string color, e.g., colors = ‘r’ or colors = ‘red’, all labels will be plotted in this color
- if a tuple of matplotlib color args (string, float, rgb, etc), different labels will be plotted in different colors in the order specified
- inline:
- controls whether the underlying contour is removed or not. Default is True.
- inline_spacing:
- space in pixels to leave on each side of label when placing inline. Defaults to 5. This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
- fmt:
- a format string for the label. Default is ‘%1.3f’ Alternatively, this can be a dictionary matching contour levels with arbitrary strings to use for each contour level (i.e., fmt[level]=string), or it can be any callable, such as a
Formatterinstance, that returns a string when called with a numeric contour level.- manual:
if True, contour labels will be placed manually using mouse clicks. Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline. Alternatively, the keyboard can be used to select label locations (enter to end label placement, delete or backspace act like the third mouse button, and any other key will select a label location).
manual can be an iterable object of x,y tuples. Contour labels will be created as if mouse is clicked at each x,y positions.
- rightside_up:
- if True (default), label rotations will always be plus or minus 90 degrees from level.
- use_clabeltext:
- if True (default is False), ClabelText class (instead of matplotlib.Text) is used to create labels. ClabelText recalculates rotation angles of texts during the drawing time, therefore this can be used if aspect of the axes changes.
matplotlib.pyplot.clf()¶Clear the current figure.
matplotlib.pyplot.clim(vmin=None, vmax=None)¶Set the color limits of the current image.
To apply clim to all axes images do:
clim(0, 0.5)
If either vmin or vmax is None, the image min/max respectively will be used for color scaling.
If you want to set the clim of multiple images, use, for example:
for im in gca().get_images(): im.set_clim(0, 0.05)
matplotlib.pyplot.close(*args)¶Close a figure window.
close() by itself closes the current figure
close(h) where h is a Figure instance, closes that figure
close(num) closes figure number num
close(name) where name is a string, closes figure with that label
close('all') closes all the figure windows
matplotlib.pyplot.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, hold=None, data=None, **kwargs)¶Plot the coherence between x and y.
Plot the coherence between x and y. Coherence is the normalized cross spectral density:

| Parameters: | Fs : scalar
window : callable or ndarray
sides : [ ‘default’ | ‘onesided’ | ‘twosided’ ]
pad_to : integer
NFFT : integer
detrend : {‘default’, ‘constant’, ‘mean’, ‘linear’, ‘none’} or callable
scale_by_freq : boolean, optional
noverlap : integer
Fc : integer
**kwargs :
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | The return value is a tuple (Cxy, f), where f are the frequencies of the coherence vector. kwargs are applied to the lines. |
References
Bendat & Piersol – Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.colorbar(mappable=None, cax=None, ax=None, **kw)¶Add a colorbar to a plot.
Function signatures for the pyplot interface; all
but the first are also method signatures for the
colorbar() method:
colorbar(**kwargs) colorbar(mappable, **kwargs) colorbar(mappable, cax=cax, **kwargs) colorbar(mappable, ax=ax, **kwargs)
arguments:
- mappable
- the
Image,ContourSet, etc. to which the colorbar applies; this argument is mandatory for thecolorbar()method but optional for thecolorbar()function, which sets the default to the current image.
keyword arguments:
- cax
- None | axes object into which the colorbar will be drawn
- ax
- None | parent axes object(s) from which space for a new colorbar axes will be stolen. If a list of axes is given they will all be resized to make room for the colorbar axes.
- use_gridspec
- False | If cax is None, a new cax is created as an instance of Axes. If ax is an instance of Subplot and use_gridspec is True, cax is created as an instance of Subplot using the grid_spec module.
Additional keyword arguments are of two kinds:
axes properties:
Property Description orientation vertical or horizontal fraction 0.15; fraction of original axes to use for colorbar pad 0.05 if vertical, 0.15 if horizontal; fraction of original axes between colorbar and new image axes shrink 1.0; fraction by which to shrink the colorbar aspect 20; ratio of long to short dimensions anchor (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal; the anchor point of the colorbar axes panchor (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal; the anchor point of the colorbar parent axes. If False, the parent axes’ anchor will be unchanged colorbar properties:
Property Description extend [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ] If not ‘neither’, make pointed end(s) for out-of- range values. These are set for a given colormap using the colormap set_under and set_over methods. extendfrac [ None | ‘auto’ | length | lengths ] If set to None, both the minimum and maximum triangular colorbar extensions with have a length of 5% of the interior colorbar length (this is the default setting). If set to ‘auto’, makes the triangular colorbar extensions the same lengths as the interior boxes (when spacing is set to ‘uniform’) or the same lengths as the respective adjacent interior boxes (when spacing is set to ‘proportional’). If a scalar, indicates the length of both the minimum and maximum triangular colorbar extensions as a fraction of the interior colorbar length. A two-element sequence of fractions may also be given, indicating the lengths of the minimum and maximum colorbar extensions respectively as a fraction of the interior colorbar length. extendrect [ False | True ] If False the minimum and maximum colorbar extensions will be triangular (the default). If True the extensions will be rectangular. spacing [ ‘uniform’ | ‘proportional’ ] Uniform spacing gives each discrete color the same space; proportional makes the space proportional to the data interval. ticks [ None | list of ticks | Locator object ] If None, ticks are determined automatically from the input. format [ None | format string | Formatter object ] If None, the ScalarFormatteris used. If a format string is given, e.g., ‘%.3f’, that is used. An alternativeFormatterobject may be given instead.drawedges [ False | True ] If true, draw lines at color boundaries. The following will probably be useful only in the context of indexed colors (that is, when the mappable has norm=NoNorm()), or other unusual circumstances.
Property Description boundaries None or a sequence values None or a sequence which must be of length 1 less than the sequence of boundaries. For each region delimited by adjacent entries in boundaries, the color mapped to the corresponding value in values will be used.
If mappable is a ContourSet, its extend
kwarg is included automatically.
Note that the shrink kwarg provides a simple way to keep a vertical colorbar, for example, from being taller than the axes of the mappable to which the colorbar is attached; but it is a manual method requiring some trial and error. If the colorbar is too tall (or a horizontal colorbar is too wide) use a smaller value of shrink.
For more precise control, you can manually specify the positions of the axes objects in which the mappable and the colorbar are drawn. In this case, do not use any of the axes properties kwargs.
It is known that some vector graphics viewer (svg and pdf) renders white gaps between segments of the colorbar. This is due to bugs in the viewers not matplotlib. As a workaround the colorbar can be rendered with overlapping segments:
cbar = colorbar() cbar.solids.set_edgecolor("face") draw()
However this has negative consequences in other circumstances. Particularly with semi transparent images (alpha < 1) and colorbar extensions and is not enabled by default see (issue #1188).
Colorbar instance; see also its base class,
ColorbarBase. Call the
set_label() method
to label the colorbar.matplotlib.pyplot.colors()¶This is a do-nothing function to provide you with help on how matplotlib handles colors.
Commands which take color arguments can use several formats to specify the colors. For the basic built-in colors, you can use a single letter
Alias Color ‘b’ blue ‘g’ green ‘r’ red ‘c’ cyan ‘m’ magenta ‘y’ yellow ‘k’ black ‘w’ white
For a greater range of colors, you have two options. You can specify the color using an html hex string, as in:
color = '#eeefff'
or you can pass an R,G,B tuple, where each of R,G,B are in the range [0,1].
You can also use any legal html name for a color, for example:
color = 'red' color = 'burlywood' color = 'chartreuse'
The example below creates a subplot with a dark slate gray background:
subplot(111, facecolor=(0.1843, 0.3098, 0.3098))
Here is an example that creates a pale turquoise title:
title('Is this the best color?', color='#afeeee')
matplotlib.pyplot.connect(s, func)¶Connect event with string s to func. The signature of func is:
def func(event)
where event is a matplotlib.backend_bases.Event. The
following events are recognized
For the location events (button and key press/release), if the
mouse is over the axes, the variable event.inaxes will be
set to the Axes the event occurs is
over, and additionally, the variables event.xdata and
event.ydata will be defined. This is the mouse location
in data coords. See
KeyEvent and
MouseEvent for more info.
Return value is a connection id that can be used with
mpl_disconnect().
Example usage:
def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = canvas.mpl_connect('button_press_event', on_press)
matplotlib.pyplot.contour(*args, **kwargs)¶Plot contours.
contour() and
contourf() draw contour lines and
filled contours, respectively. Except as noted, function
signatures and return values are the same for both versions.
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().
Call signatures:
contour(Z)
make a contour plot of an array Z. The level values are chosen automatically.
contour(X,Y,Z)
X, Y specify the (x, y) coordinates of the surface
contour(Z,N) contour(X,Y,Z,N)
contour up to N automatically-chosen levels.
contour(Z,V) contour(X,Y,Z,V)
draw contour lines at the values specified in sequence V, which must be in increasing order.
contourf(..., V)
fill the len(V)-1 regions between the values in V,
which must be in increasing order.
contour(Z, **kwargs)
Use keyword args to control colors, linewidth, origin, cmap ... see below for more details.
X and Y must both be 2-D with the same shape as Z, or they
must both be 1-D such that len(X) is the number of columns in
Z and len(Y) is the number of rows in Z.
C = contour(...) returns a
QuadContourSet object.
Optional keyword arguments:
- corner_mask: [ True | False | ‘legacy’ ]
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. If ‘legacy’, the old contouring algorithm is used, which is equivalent to False and is deprecated, only remaining whilst the new algorithm is tested fully.
If not specified, the default is taken from rcParams[‘contour.corner_mask’], which is True unless it has been modified.
- colors: [ None | string | (mpl_colors) ]
If None, the colormap specified by cmap will be used.
If a string, like ‘r’ or ‘red’, all levels will be plotted in this color.
If a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.
- alpha: float
- The alpha blending value
- cmap: [ None | Colormap ]
- A cm
Colormapinstance or None. If cmap is None and colors is None, a default Colormap is used.- norm: [ None | Normalize ]
- A
matplotlib.colors.Normalizeinstance for scaling data values to colors. If norm is None and colors is None, the default linear scaling is used.- vmin, vmax: [ None | scalar ]
- If not None, either or both of these values will be supplied to the
matplotlib.colors.Normalizeinstance, overriding the default color scaling based on levels.- levels: [level0, level1, ..., leveln]
- A list of floating point numbers indicating the level curves to draw, in increasing order; e.g., to draw just the zero contour pass
levels=[0]- origin: [ None | ‘upper’ | ‘lower’ | ‘image’ ]
If None, the first value of Z will correspond to the lower left corner, location (0,0). If ‘image’, the rc value for
image.originwill be used.This keyword is not active if X and Y are specified in the call to contour.
extent: [ None | (x0,x1,y0,y1) ]
If origin is not None, then extent is interpreted as in
matplotlib.pyplot.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 keyword is not active if X and Y are specified in the call to contour.
- locator: [ None | ticker.Locator subclass ]
- If locator is None, the default
MaxNLocatoris used. The locator is used to determine the contour levels if they are not given explicitly via the V argument.- extend: [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ]
- Unless this is ‘neither’, contour levels are automatically added to one or both ends of the range so that all data are included. These added ranges are then mapped to the special colormap values which default to the ends of the colormap range, but can be set via
matplotlib.colors.Colormap.set_under()andmatplotlib.colors.Colormap.set_over()methods.- xunits, yunits: [ None | registered units ]
- Override axis units by specifying an instance of a
matplotlib.units.ConversionInterface.- antialiased: [ True | False ]
- enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams[‘lines.antialiased’].
- nchunk: [ 0 | integer ]
- 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.
contour-only keyword arguments:
- linewidths: [ None | number | tuple of numbers ]
If linewidths is None, the default width in
lines.linewidthinmatplotlibrcis used.If a number, all levels will be plotted with this linewidth.
If a tuple, different levels will be plotted with different linewidths in the order specified.
- linestyles: [ None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
If linestyles is None, the default is ‘solid’ unless the lines are monochrome. In that case, negative contours will take their linestyle from the
matplotlibrccontour.negative_linestylesetting.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.
contourf-only keyword arguments:
- hatches:
- 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.
Note: contourf fills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is:
z1 < z <= z2
There is one exception: if the lowest boundary coincides with the minimum value of the z array, then that minimum value will be included in the lowest interval.
Examples:
(Source code, png, pdf)
matplotlib.pyplot.contourf(*args, **kwargs)¶Plot contours.
contour() and
contourf() draw contour lines and
filled contours, respectively. Except as noted, function
signatures and return values are the same for both versions.
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().
Call signatures:
contour(Z)
make a contour plot of an array Z. The level values are chosen automatically.
contour(X,Y,Z)
X, Y specify the (x, y) coordinates of the surface
contour(Z,N) contour(X,Y,Z,N)
contour up to N automatically-chosen levels.
contour(Z,V) contour(X,Y,Z,V)
draw contour lines at the values specified in sequence V, which must be in increasing order.
contourf(..., V)
fill the len(V)-1 regions between the values in V,
which must be in increasing order.
contour(Z, **kwargs)
Use keyword args to control colors, linewidth, origin, cmap ... see below for more details.
X and Y must both be 2-D with the same shape as Z, or they
must both be 1-D such that len(X) is the number of columns in
Z and len(Y) is the number of rows in Z.
C = contour(...) returns a
QuadContourSet object.
Optional keyword arguments:
- corner_mask: [ True | False | ‘legacy’ ]
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. If ‘legacy’, the old contouring algorithm is used, which is equivalent to False and is deprecated, only remaining whilst the new algorithm is tested fully.
If not specified, the default is taken from rcParams[‘contour.corner_mask’], which is True unless it has been modified.
- colors: [ None | string | (mpl_colors) ]
If None, the colormap specified by cmap will be used.
If a string, like ‘r’ or ‘red’, all levels will be plotted in this color.
If a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.
- alpha: float
- The alpha blending value
- cmap: [ None | Colormap ]
- A cm
Colormapinstance or None. If cmap is None and colors is None, a default Colormap is used.- norm: [ None | Normalize ]
- A
matplotlib.colors.Normalizeinstance for scaling data values to colors. If norm is None and colors is None, the default linear scaling is used.- vmin, vmax: [ None | scalar ]
- If not None, either or both of these values will be supplied to the
matplotlib.colors.Normalizeinstance, overriding the default color scaling based on levels.- levels: [level0, level1, ..., leveln]
- A list of floating point numbers indicating the level curves to draw, in increasing order; e.g., to draw just the zero contour pass
levels=[0]- origin: [ None | ‘upper’ | ‘lower’ | ‘image’ ]
If None, the first value of Z will correspond to the lower left corner, location (0,0). If ‘image’, the rc value for
image.originwill be used.This keyword is not active if X and Y are specified in the call to contour.
extent: [ None | (x0,x1,y0,y1) ]
If origin is not None, then extent is interpreted as in
matplotlib.pyplot.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 keyword is not active if X and Y are specified in the call to contour.
- locator: [ None | ticker.Locator subclass ]
- If locator is None, the default
MaxNLocatoris used. The locator is used to determine the contour levels if they are not given explicitly via the V argument.- extend: [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ]
- Unless this is ‘neither’, contour levels are automatically added to one or both ends of the range so that all data are included. These added ranges are then mapped to the special colormap values which default to the ends of the colormap range, but can be set via
matplotlib.colors.Colormap.set_under()andmatplotlib.colors.Colormap.set_over()methods.- xunits, yunits: [ None | registered units ]
- Override axis units by specifying an instance of a
matplotlib.units.ConversionInterface.- antialiased: [ True | False ]
- enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams[‘lines.antialiased’].
- nchunk: [ 0 | integer ]
- 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.
contour-only keyword arguments:
- linewidths: [ None | number | tuple of numbers ]
If linewidths is None, the default width in
lines.linewidthinmatplotlibrcis used.If a number, all levels will be plotted with this linewidth.
If a tuple, different levels will be plotted with different linewidths in the order specified.
- linestyles: [ None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
If linestyles is None, the default is ‘solid’ unless the lines are monochrome. In that case, negative contours will take their linestyle from the
matplotlibrccontour.negative_linestylesetting.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.
contourf-only keyword arguments:
- hatches:
- 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.
Note: contourf fills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is:
z1 < z <= z2
There is one exception: if the lowest boundary coincides with the minimum value of the z array, then that minimum value will be included in the lowest interval.
Examples:
(Source code, png, pdf)
matplotlib.pyplot.cool()¶set the default colormap to cool and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.copper()¶set the default colormap to copper and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.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, hold=None, data=None, **kwargs)¶Plot the cross-spectral density.
Call signature:
csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, return_line=None, **kwargs)
The cross spectral density
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
, 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, y : 1-D arrays or sequences
Fs : scalar
window : callable or ndarray
sides : [ ‘default’ | ‘onesided’ | ‘twosided’ ]
pad_to : integer
NFFT : integer
detrend : {‘default’, ‘constant’, ‘mean’, ‘linear’, ‘none’} or callable
scale_by_freq : boolean, optional
noverlap : integer
Fc : integer
return_line : bool
**kwargs :
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | Pxy : 1-D array
freqs : 1-D array
line : a
|
See also
Notes
For plotting, the power is plotted as
for decibels, though P_{xy} itself
is returned.
References
Bendat & Piersol – Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)
Examples
(Source code, png, pdf)
matplotlib.pyplot.delaxes(*args)¶Remove an axes from the current figure. If ax doesn’t exist, an error will be raised.
delaxes(): delete the current axes
matplotlib.pyplot.disconnect(cid)¶Disconnect callback id cid
Example usage:
cid = canvas.mpl_connect('button_press_event', on_press) #...later canvas.mpl_disconnect(cid)
matplotlib.pyplot.draw()¶Redraw the current figure.
This is used to update a figure that has been altered, but not
automatically re-drawn. If interactive mode is on (ion()), this
should be only rarely needed, but there may be ways to modify the state of
a figure without marking it as stale. Please report these cases as
bugs.
A more object-oriented alternative, given any
Figure instance, fig, that
was created using a pyplot function, is:
fig.canvas.draw_idle()
matplotlib.pyplot.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, hold=None, data=None, **kwargs)¶Plot an errorbar graph.
Plot x versus y with error deltas in yerr and xerr. Vertical errorbars are plotted if yerr is not None. Horizontal errorbars are plotted if xerr is not None.
x, y, xerr, and yerr can all be scalars, which plots a single error bar at x, y.
| Parameters: | x : scalar or array-like y : scalar or array-like xerr/yerr : scalar or array-like, shape(N,) or shape(2,N), optional
fmt : plot format string, optional, default: None
ecolor : mpl color, optional, default: None
elinewidth : scalar, optional, default: None
capsize : scalar, optional, default: None
capthick : scalar, optional, default: None
barsabove : bool, optional, default: False
lolims / uplims / xlolims / xuplims : bool, optional, default:None
errorevery : positive integer, optional, default:1
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns: | plotline :
caplines : list of
barlinecols : list of
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Other Parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kwargs : All other keyword arguments are passed on to the plot
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1, linewidths=None, colors=None, linestyles='solid', hold=None, data=None, **kwargs)¶Plot identical parallel lines at specific positions.
Plot parallel lines at the given positions. positions should be a 1D or 2D array-like object, with each row corresponding to a row or column of lines.
This type of plot is commonly used in neuroscience for representing neural events, where it is commonly 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.
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 or column in positions.
Returns a list of matplotlib.collections.EventCollection
objects that were added.
kwargs are LineCollection properties:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown pathsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] segmentsunknown sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown vertsunknown visible[True | False] zorderany number
Example:
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.figimage(*args, **kwargs)¶Adds a non-resampled image to the figure.
call signatures:
figimage(X, **kwargs)
adds a non-resampled array X to the figure.
figimage(X, xo, yo)
with pixel offsets xo, yo,
X must be a float array:
Optional keyword arguments:
Keyword Description resize a boolean, True or False. If “True”, then re-size the Figure to match the given image size. xo or yo An integer, the x and y image offset in pixels cmap a matplotlib.colors.Colormapinstance, e.g., cm.jet. If None, default to the rcimage.cmapvaluenorm a matplotlib.colors.Normalizeinstance. The default is normalization(). This scales luminance -> 0-1vmin|vmax are used to scale a luminance image to 0-1. If either is None, the min and max of the luminance values will be used. Note if you pass a norm instance, the settings for vmin and vmax will be ignored. alpha the alpha blending value, default is None origin [ ‘upper’ | ‘lower’ ] Indicates where the [0,0] index of the array is in the upper left or lower left corner of the axes. Defaults to the rc image.origin value
figimage complements the axes image
(imshow()) which will be resampled
to fit the current axes. If you want a resampled image to
fill the entire figure, you can define an
Axes with extent [0,0,1,1].
An matplotlib.image.FigureImage instance is returned.
(Source code, png, pdf)
Additional kwargs are Artist kwargs passed on to
FigureImage
matplotlib.pyplot.figlegend(handles, labels, loc, **kwargs)¶Place a legend in the figure.
Line2D or
Patch instancesA matplotlib.legend.Legend instance is returned.
Example:
figlegend( (line1, line2, line3), ('label1', 'label2', 'label3'), 'upper right' )
See also
matplotlib.pyplot.fignum_exists(num)¶matplotlib.pyplot.figtext(*args, **kwargs)¶Add text to figure.
Call signature:
text(x, y, s, fontdict=None, **kwargs)
Add text to figure at location x, y (relative 0-1
coords). See text() for the meaning
of the other arguments.
kwargs control the Text properties:
Property Description agg_filterunknown alphafloat (0.0 transparent through 1.0 opaque) animated[True | False] axesan Axesinstancebackgroundcolorany matplotlib color bboxFancyBboxPatch prop dict clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]colorany matplotlib color containsa callable function familyor fontfamily or fontname or name[FONTNAME | ‘serif’ | ‘sans-serif’ | ‘cursive’ | ‘fantasy’ | ‘monospace’ ] figurea matplotlib.figure.Figureinstancefontpropertiesor font_propertiesa matplotlib.font_manager.FontPropertiesinstancegidan id string horizontalalignmentor ha[ ‘center’ | ‘right’ | ‘left’ ] labelstring or anything printable with ‘%s’ conversion. linespacingfloat (multiple of font size) multialignment[‘left’ | ‘right’ | ‘center’ ] path_effectsunknown picker[None|float|boolean|callable] position(x,y) rasterized[True | False | None] rotation[ angle in degrees | ‘vertical’ | ‘horizontal’ ] rotation_modeunknown sizeor fontsize[size in points | ‘xx-small’ | ‘x-small’ | ‘small’ | ‘medium’ | ‘large’ | ‘x-large’ | ‘xx-large’ ] sketch_paramsunknown snapunknown stretchor fontstretch[a numeric value in range 0-1000 | ‘ultra-condensed’ | ‘extra-condensed’ | ‘condensed’ | ‘semi-condensed’ | ‘normal’ | ‘semi-expanded’ | ‘expanded’ | ‘extra-expanded’ | ‘ultra-expanded’ ] styleor fontstyle[ ‘normal’ | ‘italic’ | ‘oblique’] textstring or anything printable with ‘%s’ conversion. transformTransforminstanceurla url string usetexunknown variantor fontvariant[ ‘normal’ | ‘small-caps’ ] verticalalignmentor ma or va[ ‘center’ | ‘top’ | ‘bottom’ | ‘baseline’ ] visible[True | False] weightor fontweight[a numeric value in range 0-1000 | ‘ultralight’ | ‘light’ | ‘normal’ | ‘regular’ | ‘book’ | ‘medium’ | ‘roman’ | ‘semibold’ | ‘demibold’ | ‘demi’ | ‘bold’ | ‘heavy’ | ‘extra bold’ | ‘black’ ] wrapunknown xfloat yfloat zorderany number
matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, FigureClass=<class 'matplotlib.figure.Figure'>, **kwargs)¶Creates a new figure.
| Parameters: | num : integer or string, optional, default: none
figsize : tuple of integers, optional, default: None
dpi : integer, optional, default: None
facecolor :
edgecolor :
|
|---|---|
| Returns: | figure : Figure
|
Notes
If you are creating many figures, make sure you explicitly call “close” on the figures you are not using, because this will enable pylab to properly clean up the memory.
rcParams defines the default values, which can be modified in the matplotlibrc file
matplotlib.pyplot.fill(*args, **kwargs)¶Plot filled polygons.
| Parameters: | args : a variable length argument
|
|---|---|
| Returns: | a list of |
| Other Parameters: | |
kwargs : |
|
Notes
The same color strings that plot()
supports are supported by the fill format string.
If you would like to fill below a curve, e.g., shade a region
between 0 and y along x, use fill_between()
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, hold=None, data=None, **kwargs)¶Make filled polygons between two curves.
Create a PolyCollection
filling the regions between y1 and y2 where
where==True
| Parameters: | x : array
y1 : array
y2 : array
where : array, optional
interpolate : bool, optional
step : {‘pre’, ‘post’, ‘mid’}, optional
|
|---|
See also
Notes
Additional Keyword args passed on to the
PolyCollection.
kwargs control the Polygon properties:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number
Examples
matplotlib.pyplot.fill_betweenx(y, x1, x2=0, where=None, step=None, hold=None, data=None, **kwargs)¶Make filled polygons between two horizontal curves.
Create a PolyCollection
filling the regions between x1 and x2 where
where==True
| Parameters: | y : array
x1 : array
x2 : array, optional
where : array, optional
step : {‘pre’, ‘post’, ‘mid’}, optional
|
|---|
See also
Notes
PolyCollectionkwargs control the Polygon properties:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number
Examples
matplotlib.pyplot.findobj(o=None, match=None, include_self=True)¶Find artist objects.
Recursively find all Artist instances
contained in self.
match can be
- None: return all objects contained in artist.
- function with signature
boolean = match(artist)used to filter matches- class instance: e.g., Line2D. Only return artists of class type.
If include_self is True (default), include self in the list to be checked for a match.
matplotlib.pyplot.flag()¶set the default colormap to flag and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.gca(**kwargs)¶Get the current Axes instance on the
current figure matching the given keyword args, or create one.
See also
matplotlib.figure.Figure.gcaExamples
To get the current polar axes on the current figure:
plt.gca(projection='polar')
If the current axes doesn’t exist, or isn’t a polar one, the appropriate axes will be created and then returned.
matplotlib.pyplot.gcf()¶Get a reference to the current figure.
matplotlib.pyplot.gci()¶Get the current colorable artist. Specifically, returns the
current ScalarMappable instance (image or
patch collection), or None if no images or patch collections
have been defined. The commands imshow()
and figimage() create
Image instances, and the commands
pcolor() and
scatter() create
Collection instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
matplotlib.pyplot.get_current_fig_manager()¶matplotlib.pyplot.get_figlabels()¶Return a list of existing figure labels.
matplotlib.pyplot.get_fignums()¶Return a list of existing figure numbers.
matplotlib.pyplot.get_plot_commands()¶Get a sorted list of all of the plotting commands.
matplotlib.pyplot.ginput(*args, **kwargs)¶Blocking call to interact with the figure.
This will wait for n clicks from the user and return a list of the coordinates of each click.
If timeout is zero or negative, does not timeout.
If n is zero or negative, accumulate clicks until a middle click (or potentially both mouse buttons at once) terminates the input.
Right clicking cancels last input.
The buttons used for the various actions (adding points, removing points, terminating the inputs) can be overriden via the arguments mouse_add, mouse_pop and mouse_stop, that give the associated mouse button: 1 for left, 2 for middle, 3 for right.
The keyboard can also be used to select points in case your mouse does not have one or more of the buttons. The delete and backspace keys act like right clicking (i.e., remove last point), the enter key terminates input and any other key (not already used by the window manager) selects a point.
matplotlib.pyplot.gray()¶set the default colormap to gray and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.grid(b=None, which='major', axis='both', **kwargs)¶Turn the axes grids on or off.
Set the axes grids on or off; b is a boolean. (For MATLAB compatibility, b may also be a string, ‘on’ or ‘off’.)
If b is None and len(kwargs)==0, toggle the grid state. If
kwargs are supplied, it is assumed that you want a grid and b
is thus set to True.
which can be ‘major’ (default), ‘minor’, or ‘both’ to control whether major tick grids, minor tick grids, or both are affected.
axis can be ‘both’ (default), ‘x’, or ‘y’ to control which set of gridlines are drawn.
kwargs are used to set the grid line properties, e.g.,:
ax.grid(color='r', linestyle='-', linewidth=2)
Valid Line2D kwargs are
Property Description agg_filterunknown alphafloat (0.0 transparent through 1.0 opaque) animated[True | False] antialiasedor aa[True | False] axesan Axesinstanceclip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]coloror cany matplotlib color containsa callable function dash_capstyle[‘butt’ | ‘round’ | ‘projecting’] dash_joinstyle[‘miter’ | ‘round’ | ‘bevel’] dashessequence of on/off ink in points drawstyle[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’] figurea matplotlib.figure.Figureinstancefillstyle[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’] gidan id string labelstring or anything printable with ‘%s’ conversion. linestyleor ls[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor lwfloat value in points markerA valid marker stylemarkeredgecoloror mecany matplotlib color markeredgewidthor mewfloat value in points markerfacecoloror mfcany matplotlib color markerfacecoloraltor mfcaltany matplotlib color markersizeor msfloat markevery[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float] path_effectsunknown pickerfloat distance in points or callable pick function fn(artist, event)pickradiusfloat distance in points rasterized[True | False | None] sketch_paramsunknown snapunknown solid_capstyle[‘butt’ | ‘round’ | ‘projecting’] solid_joinstyle[‘miter’ | ‘round’ | ‘bevel’] transforma matplotlib.transforms.Transforminstanceurla url string visible[True | False] xdata1D array ydata1D array zorderany number
matplotlib.pyplot.hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', yscale='linear', extent=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors='none', reduce_C_function=<function mean>, mincnt=None, marginals=False, hold=None, data=None, **kwargs)¶Make a hexagonal binning plot.
Make a hexagonal binning plot of x versus y, where x, y are 1-D sequences of the same length, N. If C is None (the default), this is a histogram of the number of occurences of the observations at (x[i],y[i]).
If C is specified, it specifies values at the coordinate (x[i],y[i]). These values are accumulated for each hexagonal bin and then reduced according to reduce_C_function, which defaults to numpy’s mean function (np.mean). (If C is specified, it must also be a 1-D sequence of the same length as x and y.)
| Parameters: | x, y : array or masked array C : array or masked array, optional, default is None gridsize : int or (int, int), optional, default is 100
bins : {‘log’} or int or sequence, optional, default is None
xscale : {‘linear’, ‘log’}, optional, default is ‘linear’
yscale : {‘linear’, ‘log’}, optional, default is ‘linear’
mincnt : int > 0, optional, default is None
marginals : bool, optional, default is False
extent : scalar, optional, default is None
|
|---|---|
| Returns: | object
|
| Other Parameters: | |
cmap : object, optional, default is None
norm : object, optional, default is None
vmin, vmax : scalar, optional, default is None
alpha : scalar between 0 and 1, optional, default is None
linewidths : scalar, optional, default is None
edgecolors : {‘none’} or mpl color, optional, default is ‘none’
|
|
Notes
The standard descriptions of all the
Collection parameters:
Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown axesan Axesinstanceclima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
Examples
(Source code, png, pdf)
matplotlib.pyplot.hist(x, bins=None, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs)¶Plot a histogram.
Compute and draw the histogram of x. The return value is a tuple (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1,...]) if the input contains multiple data.
Multiple data can be provided via x as a list of datasets of potentially different length ([x0, x1, ...]), or as a 2-D ndarray in which each column is a dataset. Note that the ndarray form is transposed relative to the list form.
Masked arrays are not supported at present.
| Parameters: | x : (n,) array or sequence of (n,) arrays
bins : integer or array_like or ‘auto’, optional
range : tuple or None, optional
normed : boolean, optional
weights : (n, ) array_like or None, optional
cumulative : boolean, optional
bottom : array_like, scalar, or None
histtype : {‘bar’, ‘barstacked’, ‘step’, ‘stepfilled’}, optional
align : {‘left’, ‘mid’, ‘right’}, optional
orientation : {‘horizontal’, ‘vertical’}, optional
rwidth : scalar or None, optional
log : boolean, optional
color : color or array_like of colors or None, optional
label : string or None, optional
stacked : boolean, optional
|
|---|---|
| Returns: | n : array or list of arrays
bins : array
patches : list or list of lists
|
| Other Parameters: | |
kwargs : |
|
See also
hist2dNotes
Until numpy release 1.5, the underlying numpy histogram function was
incorrect with normed`=`True if bin sizes were unequal. MPL
inherited that error. It is now corrected within MPL when using
earlier numpy versions.
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None, cmax=None, hold=None, data=None, **kwargs)¶Make a 2D histogram plot.
| Parameters: | x, y: array_like, shape (n, )
bins: [None | int | [int, int] | array_like | [array, array]]
range : array_like shape(2, 2), optional, default: None
normed : boolean, optional, default: False
weights : array_like, shape (n, ), optional, default: None
cmin : scalar, optional, default: None
cmax : scalar, optional, default: None
|
|---|---|
| Returns: | The return value is |
| Other Parameters: | |
cmap : {Colormap, string}, optional
norm : Normalize, optional
vmin/vmax : {None, scalar}, optional
alpha :
|
|
See also
histNotes
Rendering the histogram with a logarithmic color scale is
accomplished by passing a colors.LogNorm instance to
the norm keyword argument. Likewise, power-law normalization
(similar in effect to gamma correction) can be accomplished with
colors.PowerNorm.
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.hlines(y, xmin, xmax, colors='k', linestyles='solid', label='', hold=None, data=None, **kwargs)¶Plot horizontal lines at each y from xmin to xmax.
| Parameters: | y : scalar or sequence of scalar
xmin, xmax : scalar or 1D array_like
colors : array_like of colors, optional, default: ‘k’ linestyles : [‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’], optional label : string, optional, default: ‘’ |
|---|---|
| Returns: | lines : |
| Other Parameters: | |
kwargs : |
|
See also
vlinesExamples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.hold(b=None)¶Deprecated since version 2.0: pyplot.hold is deprecated. Future behavior will be consistent with the long-time default: plot commands add elements without first clearing the Axes and/or Figure.
Set the hold state. If b is None (default), toggle the hold state, else set the hold state to boolean value b:
hold() # toggle hold hold(True) # hold is on hold(False) # hold is off
When hold is True, subsequent plot commands will add elements to the current axes. When hold is False, the current axes and figure will be cleared on the next plot command.
matplotlib.pyplot.hot()¶set the default colormap to hot and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.hsv()¶set the default colormap to hsv and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.imread(*args, **kwargs)¶Read an image from a file into an array.
fname may be a string path, a valid URL, or a Python file-like object. If using a file object, it must be opened in binary mode.
If format is provided, will try to read file of that type, otherwise the format is deduced from the filename. If nothing can be deduced, PNG is tried.
Return value is a numpy.array. For grayscale images, the
return array is MxN. For RGB images, the return value is MxNx3.
For RGBA images the return value is MxNx4.
matplotlib can only read PNGs natively, but if PIL is installed, it will
use it to load the image and return an array (if possible) which
can be used with imshow(). Note, URL strings
may not be compatible with PIL. Check the PIL documentation for more
information.
matplotlib.pyplot.imsave(*args, **kwargs)¶Save an array as in image file.
The output formats available depend on the backend being used.
matplotlib.pyplot.imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None, data=None, **kwargs)¶Display an image on the axes.
| Parameters: | X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)
cmap :
aspect : [‘auto’ | ‘equal’ | scalar], optional, default: None
interpolation : string, optional, default: None
norm : vmin, vmax : scalar, optional, default: None
alpha : scalar, optional, default: None
origin : [‘upper’ | ‘lower’], optional, default: None
extent : scalars (left, right, bottom, top), optional, default: None
shape : scalars (columns, rows), optional, default: None
filternorm : scalar, optional, default: 1
filterrad : scalar, optional, default: 4.0
|
|---|---|
| Returns: | image : |
| Other Parameters: | |
kwargs : |
|
See also
matshowNotes
Unless extent is used, pixel centers will be located at integer coordinates. In other words: the origin will coincide with the center of pixel (0, 0).
Examples
(Source code, png, pdf)
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
matplotlib.pyplot.inferno()¶set the default colormap to inferno and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.install_repl_displayhook()¶Install a repl display hook so that any stale figure are automatically redrawn when control is returned to the repl.
This works with IPython terminals and kernels, as well as vanilla python shells.
matplotlib.pyplot.ioff()¶Turn interactive mode off.
matplotlib.pyplot.ion()¶Turn interactive mode on.
matplotlib.pyplot.ishold()¶Deprecated since version 2.0: pyplot.hold is deprecated. Future behavior will be consistent with the long-time default: plot commands add elements without first clearing the Axes and/or Figure.
Return the hold status of the current axes.
matplotlib.pyplot.isinteractive()¶Return status of interactive mode.
matplotlib.pyplot.jet()¶set the default colormap to jet and apply to current image if any. See help(colormaps) for more information
matplotlib.pyplot.legend(*args, **kwargs)¶Places a legend on the axes.
To make a legend for lines which already exist on the axes (via plot for instance), simply call this function with an iterable of strings, one for each legend item. For example:
ax.plot([1, 2, 3]) ax.legend(['A simple line'])
However, in order to keep the “label” and the legend element
instance together, it is preferable to specify the label either at
artist creation, or by calling the
set_label() method on the artist:
line, = ax.plot([1, 2, 3], label='Inline label') # Overwrite the label by calling the method. line.set_label('Label via method') ax.legend()
Specific lines can be excluded from the automatic legend element
selection by defining a label starting with an underscore.
This is default for all artists, so calling legend() without
any arguments and without setting the labels manually will result in
no legend being drawn.
For full control of which artists have a legend entry, it
[Page truncated to keep GeezerVison snappy.]