| | |
- acorr(*args, **kwargs)
- call signature::
acorr(x, normed=False, detrend=mlab.detrend_none, usevlines=False,
maxlags=None, **kwargs)
Plot the autocorrelation of x. If normed=True, normalize the
data but the autocorrelation at 0-th lag. x is detrended by
the detrend callable (default no normalization.
data are plotted as ``plot(lags, c, **kwargs)``
return value is lags, c, line where lags are a length
2*maxlags+1 lag vector, c is the 2*maxlags+1 auto correlation
vector, and line is a Line2D instance returned by plot. The
default linestyle is None and the default marker is 'o',
though these can be overridden with keyword args. The cross
correlation is performed with numpy correlate with
mode=2.
If usevlines is True, Axes.vlines rather than Axes.plot is used
to draw vertical lines from the origin to the acorr.
Otherwise the plotstyle is determined by the kwargs, which are
Line2D properties. If usevlines, the return value is lags, c,
linecol, b where linecol is the collections.LineCollection and b is the x-axis
if usevlines=True, kwargs are passed onto Axes.vlines
if usevlines=False, kwargs are passed onto Axes.plot
maxlags is a positive integer detailing the number of lags to show.
The default value of None will return all (2*len(x)-1) lags.
See the respective function for documentation on valid kwargs
Additional kwargs: hold = [True|False] overrides default hold state
- annotate(*args, **kwargs)
- call signature::
annotate(s, xy,
xytext=None,
xycoords='data',
textcoords='data',
arrowprops=None,
**props)
Annotate the x,y point xy with text s at x,y location xytext
(xytext if None defaults to xy and textcoords if None defaults
to xycoords).
arrowprops, if not None, is a dictionary of line properties
(see matplotlib.lines.Line2D) for the arrow that connects
annotation to the point. Valid keys are
========= ===========================================================
Key Description
========= ===========================================================
width the width of the arrow in points
frac the fraction of the arrow length occupied by the head
headwidth the width of the base of the arrow head in points
shrink often times it is convenient to have the arrowtip
and base a bit away from the text and point being
annotated. If d is the distance between the text and
annotated point, shrink will shorten the arrow so the tip
and base are shink percent of the distance d away from the
endpoints. ie, shrink=0.05 is 5%
? any key for matplotlib.patches.polygon
========= ===========================================================
xycoords and textcoords are strings that indicate the
coordinates of xy and xytext.
================= ===================================================
Property Description
================= ===================================================
'figure points' points from the lower left corner of the figure
'figure pixels' pixels from the lower left corner of the figure
'figure fraction' 0,0 is lower left of figure and 1,1 is upper, right
'axes points' points from lower left corner of axes
'axes pixels' pixels from lower left corner of axes
'axes fraction' 0,1 is lower left of axes and 1,1 is upper right
'data' use the coordinate system of the object being
annotated (default)
'offset points' Specify an offset (in points) from the xy value
'polar' you can specify theta, r for the annotation, even
in cartesian plots. Note that if you
are using a polar axes, you do not need
to specify polar for the coordinate
system since that is the native"data" coordinate
system.
================= ===================================================
If a points or pixels option is specified, values will be
added to the left, bottom and if negative, values will be
subtracted from the top, right. Eg::
# 10 points to the right of the left border of the axes and
# 5 points below the top border
xy=(10,-5), xycoords='axes points'
Additional kwargs are Text properties:
alpha: float
animated: [True | False]
axes: an axes instance
backgroundcolor: any matplotlib color
bbox: rectangle prop dict plus key 'pad' which is a pad in points
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color: any matplotlib color
contains: unknown
family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure: a matplotlib.figure.Figure instance
fontproperties: a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
label: any string
linespacing: float
lod: [True | False]
multialignment: ['left' | 'right' | 'center' ]
name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
picker: [None|float|boolean|callable]
position: (x,y)
rotation: [ angle in degrees 'vertical' | 'horizontal'
size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle: [ 'normal' | 'italic' | 'oblique']
text: string or anything printable with '%s' conversion
transform: a matplotlib.transform transformation instance
variant: [ 'normal' | 'small-caps' ]
verticalalignment or va: [ 'center' | 'top' | 'bottom' | 'baseline' ]
visible: [True | False]
weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x: float
y: float
zorder: any number
- arrow(*args, **kwargs)
- Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
Optional kwargs control the arrow properties:
aa: [True | False] or None for default
alpha: float
animated: [True | False]
antialiased: [True | False] or None for default
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
contains: unknown
ec: mpl color spec, or None for default, or 'none' for no color
edgecolor: mpl color spec, or None for default, or 'none' for no color
facecolor: mpl color spec, or None for default, or 'none' for no color
fc: mpl color spec, or None for default, or 'none' for no color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth: float or None for default
lod: [True | False]
lw: float or None for default
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- autumn()
- set the default colormap to autumn and apply to current image if any.
See help(colormaps) for more information
- axes(*args, **kwargs)
- Add an axes at positon rect specified by::
axes() by itself creates a default full subplot(111) window axis
axes(rect, axisbg='w') where rect=[left, bottom, width, height] in
normalized (0,1) units. axisbg 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
kwargs:
axisbg=color : the axes background color
frameon=False : don't display the frame
sharex=otherax : the current axes shares xaxis attribute with otherax
sharey=otherax : the current axes shares yaxis attribute with otherax
polar=True|False : use a polar axes or not
Examples
examples/axes_demo.py places custom axes.
examples/shared_axis_demo.py uses sharex and sharey
- axhline(*args, **kwargs)
- AXHLINE(y=0, xmin=0, xmax=1, **kwargs)
Axis Horizontal Line
Draw a horizontal line at y from xmin to xmax. With the default
values of xmin=0 and xmax=1, this line will always span the horizontal
extent of the axes, regardless of the xlim settings, even if you
change them, eg with the 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.
Return value is the Line2D instance. kwargs are the same as kwargs to
plot, and can be used to control the line properties. Eg
# 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 the middle half of
# the xrange
axhline(y=.5, xmin=0.25, xmax=0.75)
Valid kwargs are Line2D properties
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: unknown
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color or c: any matplotlib color
contains: unknown
dash_capstyle: ['butt' | 'round' | 'projecting']
dash_joinstyle: ['miter' | 'round' | 'bevel']
dashes: sequence of on/off ink in points
data: (np.array xdata, np.array ydata)
figure: a matplotlib.figure.Figure instance
label: any string
linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw: float value in points
lod: [True | False]
marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec: any matplotlib color
markeredgewidth or mew: float value in points
markerfacecolor or mfc: any matplotlib color
markersize or ms: float
picker: unknown
pickradius: unknown
solid_capstyle: ['butt' | 'round' | 'projecting']
solid_joinstyle: ['miter' | 'round' | 'bevel']
transform: a matplotlib.transforms.Transform instance
visible: [True | False]
xdata: np.array
ydata: np.array
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- axhspan(*args, **kwargs)
- AXHSPAN(ymin, ymax, xmin=0, xmax=1, **kwargs)
Axis Horizontal Span. ycoords are in data units and x
coords are in axes (relative 0-1) units
Draw a horizontal span (regtangle) from ymin to ymax. With the
default values of xmin=0 and xmax=1, this always span the xrange,
regardless of the xlim settings, even if you change them, eg with the
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.
kwargs are the kwargs to Patch, eg
antialiased, aa
linewidth, lw
edgecolor, ec
facecolor, fc
the terms on the right are aliases
Return value is the patches.Polygon instance.
#draws a gray rectangle from y=0.25-0.75 that spans the horizontal
#extent of the axes
axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
Valid kwargs are Polygon properties
aa: [True | False] or None for default
alpha: float
animated: [True | False]
antialiased: [True | False] or None for default
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
contains: unknown
ec: mpl color spec, or None for default, or 'none' for no color
edgecolor: mpl color spec, or None for default, or 'none' for no color
facecolor: mpl color spec, or None for default, or 'none' for no color
fc: mpl color spec, or None for default, or 'none' for no color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth: float or None for default
lod: [True | False]
lw: float or None for default
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- axis(*v, **kwargs)
- Set/Get the axis properties::
v = axis() returns the current axes as v = [xmin, xmax, ymin, ymax]
axis(v) where v = [xmin, xmax, ymin, ymax] sets the min and max
of the x and y axes
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') or 'normal' (deprecated) restores 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 w/o changing the others.
See help(xlim) and help(ylim) for more information
The xmin, xmax, ymin, ymax tuple is returned
- axvline(*args, **kwargs)
- AXVLINE(x=0, ymin=0, ymax=1, **kwargs)
Axis Vertical Line
Draw a vertical line at x from ymin to ymax. With the default values
of ymin=0 and ymax=1, this line will always span the vertical extent
of the axes, regardless of the xlim settings, even if you change them,
eg with the xlim command. That is, the vertical extent is in axes
coords: 0=bottom, 0.5=middle, 1.0=top but the x location is in data
coordinates.
Return value is the Line2D instance. kwargs are the same as
kwargs to plot, and can be used to control the line properties. Eg
# draw a thick red vline at x=0 that spans the yrange
l = axvline(linewidth=4, color='r')
# draw a default vline at x=1 that spans the yrange
l = axvline(x=1)
# draw a default vline at x=.5 that spans the the middle half of
# the yrange
axvline(x=.5, ymin=0.25, ymax=0.75)
Valid kwargs are Line2D properties
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: unknown
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color or c: any matplotlib color
contains: unknown
dash_capstyle: ['butt' | 'round' | 'projecting']
dash_joinstyle: ['miter' | 'round' | 'bevel']
dashes: sequence of on/off ink in points
data: (np.array xdata, np.array ydata)
figure: a matplotlib.figure.Figure instance
label: any string
linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw: float value in points
lod: [True | False]
marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec: any matplotlib color
markeredgewidth or mew: float value in points
markerfacecolor or mfc: any matplotlib color
markersize or ms: float
picker: unknown
pickradius: unknown
solid_capstyle: ['butt' | 'round' | 'projecting']
solid_joinstyle: ['miter' | 'round' | 'bevel']
transform: a matplotlib.transforms.Transform instance
visible: [True | False]
xdata: np.array
ydata: np.array
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- axvspan(*args, **kwargs)
- AXVSPAN(xmin, xmax, ymin=0, ymax=1, **kwargs)
axvspan : Axis Vertical Span. xcoords are in data units and y coords
are in axes (relative 0-1) units
Draw a vertical span (regtangle) from xmin to xmax. With the default
values of ymin=0 and ymax=1, this always span the yrange, regardless
of the ylim settings, even if you change them, eg with the 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.
kwargs are the kwargs to Patch, eg
antialiased, aa
linewidth, lw
edgecolor, ec
facecolor, fc
the terms on the right are aliases
return value is the patches.Polygon instance.
# draw a vertical green translucent rectangle from x=1.25 to 1.55 that
# spans the yrange of the axes
axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
Valid kwargs are Polygon properties
aa: [True | False] or None for default
alpha: float
animated: [True | False]
antialiased: [True | False] or None for default
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
contains: unknown
ec: mpl color spec, or None for default, or 'none' for no color
edgecolor: mpl color spec, or None for default, or 'none' for no color
facecolor: mpl color spec, or None for default, or 'none' for no color
fc: mpl color spec, or None for default, or 'none' for no color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth: float or None for default
lod: [True | False]
lw: float or None for default
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- bar(*args, **kwargs)
- BAR(left, height, width=0.8, bottom=0,
color=None, edgecolor=None, linewidth=None,
yerr=None, xerr=None, ecolor=None, capsize=3,
align='edge', orientation='vertical', log=False)
Make a bar plot with rectangles bounded by
left, left+width, bottom, bottom+height
(left, right, bottom and top edges)
left, height, width, and bottom can be either scalars or sequences
Return value is a list of Rectangle patch instances
left - the x coordinates of the left sides of the bars
height - the heights of the bars
Optional arguments:
width - the widths of the bars
bottom - the y coordinates of the bottom edges of the bars
color - the colors of the bars
edgecolor - the colors of the bar edges
linewidth - width of bar edges; None means use default
linewidth; 0 means don't draw edges.
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize (default 3) determines the length in points of the error
bar caps
align = 'edge' (default) | 'center'
orientation = 'vertical' | 'horizontal'
log = False | True - False (default) leaves the orientation
axis as-is; True sets it to log scale
For vertical bars, align='edge' aligns bars by their left edges in
left, while 'center' interprets these values as the x coordinates of
the bar centers. For horizontal bars, 'edge' aligns bars by their
bottom edges in bottom, while 'center' interprets these values as the
y coordinates of the bar centers.
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.
Optional kwargs:
aa: [True | False] or None for default
alpha: float
animated: [True | False]
antialiased: [True | False] or None for default
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
contains: unknown
ec: mpl color spec, or None for default, or 'none' for no color
edgecolor: mpl color spec, or None for default, or 'none' for no color
facecolor: mpl color spec, or None for default, or 'none' for no color
fc: mpl color spec, or None for default, or 'none' for no color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth: float or None for default
lod: [True | False]
lw: float or None for default
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- barh(*args, **kwargs)
- BARH(bottom, width, height=0.8, left=0, **kwargs)
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
Return value is a list of Rectangle patch instances
bottom - the vertical positions of the bottom edges of the bars
width - the lengths of the bars
Optional arguments:
height - the heights (thicknesses) of the bars
left - the x coordinates of the left edges of the bars
color - the colors of the bars
edgecolor - the colors of the bar edges
linewidth - width of bar edges; None means use default
linewidth; 0 means don't draw edges.
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize (default 3) determines the length in points of the error
bar caps
align = 'edge' (default) | 'center'
log = False | True - False (default) leaves the horizontal
axis as-is; True sets it to log scale
Setting align='edge' aligns bars by their bottom edges in bottom,
while 'center' interprets these values as the y coordinates of the bar
centers.
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 barh as the basis for stacked bar charts, or
candlestick plots.
Optional kwargs:
aa: [True | False] or None for default
alpha: float
animated: [True | False]
antialiased: [True | False] or None for default
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
contains: unknown
ec: mpl color spec, or None for default, or 'none' for no color
edgecolor: mpl color spec, or None for default, or 'none' for no color
facecolor: mpl color spec, or None for default, or 'none' for no color
fc: mpl color spec, or None for default, or 'none' for no color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth: float or None for default
lod: [True | False]
lw: float or None for default
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- bone()
- set the default colormap to bone and apply to current image if any.
See help(colormaps) for more information
- box(on=None)
- Turn the axes box on or off according to 'on'
If on is None, toggle state
- boxplot(*args, **kwargs)
- boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None)
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.
notch = 0 (default) produces a rectangular box plot.
notch = 1 will produce a notched box plot
sym (default 'b+') is the default symbol for flier points.
Enter an empty string ('') if you don't want to show fliers.
vert = 1 (default) makes the boxes vertical.
vert = 0 makes horizontal boxes. This seems goofy, but
that's how Matlab did it.
whis (default 1.5) defines the length of the whiskers as
a function of the inner quartile range. They extend to the
most extreme data point within ( whis*(75%-25%) ) data range.
positions (default 1,2,...,n) sets the horizontal positions of
the boxes. The ticks and limits are automatically set to match
the positions.
widths is either a scalar or a vector and sets the width of
each box. The default is 0.5, or 0.15*(distance between extreme
positions) if that is smaller.
x is an array or a sequence of vectors.
Returns a list of the lines added.
Additional kwargs: hold = [True|False] overrides default hold state
- broken_barh(*args, **kwargs)
- A collection of horizontal bars spanning yrange with a sequence of
xranges
xranges : sequence of (xmin, xwidth)
yrange : (ymin, ywidth)
kwargs are collections.BrokenBarHCollection properties
alpha: float
animated: [True | False]
antialiased: Boolean or sequence of booleans
antialiaseds: Boolean or sequence of booleans
array: unknown
axes: an axes instance
clim: a length 2 sequence of floats
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
cmap: a colormap
color: matplotlib color arg or sequence of rgba tuples
colorbar: unknown
contains: unknown
dashes: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) ]
edgecolor: matplotlib color arg or sequence of rgba tuples
edgecolors: matplotlib color arg or sequence of rgba tuples
facecolor: matplotlib color arg or sequence of rgba tuples
facecolors: matplotlib color arg or sequence of rgba tuples
figure: a matplotlib.figure.Figure instance
label: any string
linestyle: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) ]
linestyles: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) ]
linewidth: float or sequence of floats
linewidths: float or sequence of floats
lod: [True | False]
lw: float or sequence of floats
norm: unknown
picker: [None|float|boolean|callable]
pickradius: unknown
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number
these can either be a single argument, ie facecolors='black'
or a sequence of arguments for the various bars, ie
facecolors='black', 'red', 'green'
Additional kwargs: hold = [True|False] overrides default hold state
- cla(*args, **kwargs)
- Clear the current axes
- clabel(*args, **kwargs)
- clabel(CS, **kwargs) - add labels to line contours in CS,
where CS is a ContourSet object returned by contour.
clabel(CS, V, **kwargs) - only label contours listed in V
keyword arguments:
* fontsize = None: as described in http://matplotlib.sf.net/fonts.html
* colors = None:
- a tuple of matplotlib color args (string, float, rgb, etc),
different labels will be plotted in different colors in the order
specified
- one string color, e.g. colors = 'r' or colors = 'red', all labels
will be plotted in this color
- if colors == None, the color of each label matches the color
of the corresponding contour
* inline = True: controls whether the underlying contour is removed
(inline = True) or not (False)
* fmt = '%1.3f': a format string for the label
Additional kwargs: hold = [True|False] overrides default hold state
- clf()
- Clear the current figure
- 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)
- close(*args)
- Close a figure window
close() by itself closes the current figure
close(num) closes figure number num
close(h) where h is a figure handle(instance) closes that figure
close('all') closes all the figure windows
- cohere(*args, **kwargs)
- COHERE(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
window = mlab.window_hanning, noverlap=0, **kwargs)
cohere the coherence between x and y. Coherence is the normalized
cross spectral density
Cxy = |Pxy|^2/(Pxx*Pyy)
The return value is (Cxy, f), where f are the frequencies of the
coherence vector.
See the PSD help for a description of the optional parameters.
kwargs are applied to the lines
Returns the tuple Cxy, freqs
Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
kwargs control the Line2D properties of the coherence plot:
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: unknown
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color or c: any matplotlib color
contains: unknown
dash_capstyle: ['butt' | 'round' | 'projecting']
dash_joinstyle: ['miter' | 'round' | 'bevel']
dashes: sequence of on/off ink in points
data: (np.array xdata, np.array ydata)
figure: a matplotlib.figure.Figure instance
label: any string
linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw: float value in points
lod: [True | False]
marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec: any matplotlib color
markeredgewidth or mew: float value in points
markerfacecolor or mfc: any matplotlib color
markersize or ms: float
picker: unknown
pickradius: unknown
solid_capstyle: ['butt' | 'round' | 'projecting']
solid_joinstyle: ['miter' | 'round' | 'bevel']
transform: a matplotlib.transforms.Transform instance
visible: [True | False]
xdata: np.array
ydata: np.array
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- 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 Figure.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 the Figure.colorbar
method but optional for the pyplot.colorbar 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 from which space for a new
colorbar axes will be stolen
**kwargs are in two groups:
axes properties:
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
colorbar properties:
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.
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 ScalarFormatter is used.
If a format string is given, e.g. '%.3f', that is used.
An alternative Formatter object 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.
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.
- colormaps()
- matplotlib provides the following colormaps.
autumn bone cool copper flag gray hot hsv jet pink prism
spring summer winter spectral
You can set the colormap for an image, pcolor, scatter, etc,
either as a keyword argumentdef con
>>> imshow(X, cmap=cm.hot)
or post-hoc using the corresponding pylab interface function
>>> imshow(X)
>>> hot()
>>> jet()
In interactive mode, this will update the colormap allowing you to
see which one works best for your data.
- 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 builtin colors, you can use a
single letter
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, like 'red',
'burlywood' and 'chartreuse'
The example below creates a subplot with a dark
slate gray background
subplot(111, axisbg=(0.1843, 0.3098, 0.3098))
Here is an example that creates a pale turqoise title
title('Is this the best color?', color='#afeeee')
- connect(s, func)
- Connect event with string s to func. The signature of func is
def func(event)
where event is a MplEvent. The following events are recognized
'resize_event',
'draw_event',
'key_press_event',
'key_release_event',
'button_press_event',
'button_release_event',
'scroll_event',
'motion_notify_event',
'pick_event',
For the three events above, if the mouse is over the axes,
the variable event.inaxes will be set to the axes it is over,
and additionally, the variables event.xdata and event.ydata
will be defined. This is the mouse location in data coords.
See backend_bases.MplEvent.
return value is a connection id that can be used with
mpl_disconnect
- contour(*args, **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.
contourf differs from the Matlab (TM) version in that it does not
draw the polygon edges, because the contouring engine yields
simply connected regions with branch cuts. To draw the edges,
add line contours with calls to contour.
Function 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) and contour(X,Y,Z,N) - contour N automatically-chosen
levels.
contour(Z,V) and contour(X,Y,Z,V) - draw len(V) contour lines,
at the values specified in sequence V
contourf(..., V) - fill the (len(V)-1) regions between the
values in V
contour(Z, **kwargs) - Use keyword args to control colors, linewidth,
origin, cmap ... see below
X, Y, and Z must be arrays with the same dimensions.
Z may be a masked array, but filled contouring may not handle
internal masked regions correctly.
C = contour(...) returns a ContourSet object.
Optional keyword args are shown with their defaults below (you must
use kwargs for these):
* colors = None; or one of the following:
- a tuple of matplotlib color args (string, float, rgb, etc),
different levels will be plotted in different colors in the order
specified
- one string color, e.g. colors = 'r' or colors = 'red', all levels
will be plotted in this color
- if colors == None, the colormap specified by cmap will be used
* alpha=1.0 : the alpha blending value
* cmap = None: a cm Colormap instance from matplotlib.cm.
- if cmap == None and colors == None, a default Colormap is used.
* norm = None: a matplotlib.colors.Normalize instance for
scaling data values to colors.
- if norm == None, and colors == None, the default
linear scaling is used.
* origin = None: 'upper'|'lower'|'image'|None.
If 'image', the rc value for image.origin will be used.
If None (default), the first value of Z will correspond
to the lower left corner, location (0,0).
This keyword is active only if contourf is called with
one or two arguments, that is, without explicitly
specifying X and Y.
* extent = None: (x0,x1,y0,y1); also active only if X and Y
are not specified. 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].
* locator = None: an instance of a ticker.Locator subclass;
default is MaxNLocator. It 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' (default), 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
Colormap.set_under() and Colormap.set_over() methods.
****************
contour only:
* linewidths = None: or one of these:
- a number - all levels will be plotted with this linewidth,
e.g. linewidths = 0.6
- a tuple of numbers, e.g. linewidths = (0.4, 0.8, 1.2) different
levels will be plotted with different linewidths in the order
specified
- if linewidths == None, the default width in lines.linewidth in
matplotlibrc is used
contourf only:
* antialiased = True (default) or False
* nchunk = 0 (default) for no subdivision of the domain;
specify a positive integer to divide the domain into
subdomains of roughly nchunk by nchunk points. This may
never actually be advantageous, so this option may be
removed. Chunking introduces artifacts at the chunk
boundaries unless antialiased = False
Additional kwargs: hold = [True|False] overrides default hold state
- contourf(*args, **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.
contourf differs from the Matlab (TM) version in that it does not
draw the polygon edges, because the contouring engine yields
simply connected regions with branch cuts. To draw the edges,
add line contours with calls to contour.
Function 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) and contour(X,Y,Z,N) - contour N automatically-chosen
levels.
contour(Z,V) and contour(X,Y,Z,V) - draw len(V) contour lines,
at the values specified in sequence V
contourf(..., V) - fill the (len(V)-1) regions between the
values in V
contour(Z, **kwargs) - Use keyword args to control colors, linewidth,
origin, cmap ... see below
X, Y, and Z must be arrays with the same dimensions.
Z may be a masked array, but filled contouring may not handle
internal masked regions correctly.
C = contour(...) returns a ContourSet object.
Optional keyword args are shown with their defaults below (you must
use kwargs for these):
* colors = None; or one of the following:
- a tuple of matplotlib color args (string, float, rgb, etc),
different levels will be plotted in different colors in the order
specified
- one string color, e.g. colors = 'r' or colors = 'red', all levels
will be plotted in this color
- if colors == None, the colormap specified by cmap will be used
* alpha=1.0 : the alpha blending value
* cmap = None: a cm Colormap instance from matplotlib.cm.
- if cmap == None and colors == None, a default Colormap is used.
* norm = None: a matplotlib.colors.Normalize instance for
scaling data values to colors.
- if norm == None, and colors == None, the default
linear scaling is used.
* origin = None: 'upper'|'lower'|'image'|None.
If 'image', the rc value for image.origin will be used.
If None (default), the first value of Z will correspond
to the lower left corner, location (0,0).
This keyword is active only if contourf is called with
one or two arguments, that is, without explicitly
specifying X and Y.
* extent = None: (x0,x1,y0,y1); also active only if X and Y
are not specified. 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].
* locator = None: an instance of a ticker.Locator subclass;
default is MaxNLocator. It 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' (default), 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
Colormap.set_under() and Colormap.set_over() methods.
****************
contour only:
* linewidths = None: or one of these:
- a number - all levels will be plotted with this linewidth,
e.g. linewidths = 0.6
- a tuple of numbers, e.g. linewidths = (0.4, 0.8, 1.2) different
levels will be plotted with different linewidths in the order
specified
- if linewidths == None, the default width in lines.linewidth in
matplotlibrc is used
contourf only:
* antialiased = True (default) or False
* nchunk = 0 (default) for no subdivision of the domain;
specify a positive integer to divide the domain into
subdomains of roughly nchunk by nchunk points. This may
never actually be advantageous, so this option may be
removed. Chunking introduces artifacts at the chunk
boundaries unless antialiased = False
Additional kwargs: hold = [True|False] overrides default hold state
- cool()
- set the default colormap to cool and apply to current image if any.
See help(colormaps) for more information
- copper()
- set the default colormap to copper and apply to current image if any.
See help(colormaps) for more information
- csd(*args, **kwargs)
- CSD(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=window_hanning, noverlap=0, **kwargs)
The cross spectral density Pxy by Welches 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. The product of the direct FFTs of x and y are averaged over
each segment to compute Pxy, with a scaling to correct for power loss
due to windowing.
See the PSD help for a description of the optional parameters.
Returns the tuple Pxy, freqs. Pxy is the cross spectrum (complex
valued), and 10*np.log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
kwargs control the Line2D properties:
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: unknown
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color or c: any matplotlib color
contains: unknown
dash_capstyle: ['butt' | 'round' | 'projecting']
dash_joinstyle: ['miter' | 'round' | 'bevel']
dashes: sequence of on/off ink in points
data: (np.array xdata, np.array ydata)
figure: a matplotlib.figure.Figure instance
label: any string
linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw: float value in points
lod: [True | False]
marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec: any matplotlib color
markeredgewidth or mew: float value in points
markerfacecolor or mfc: any matplotlib color
markersize or ms: float
picker: unknown
pickradius: unknown
solid_capstyle: ['butt' | 'round' | 'projecting']
solid_joinstyle: ['miter' | 'round' | 'bevel']
transform: a matplotlib.transforms.Transform instance
visible: [True | False]
xdata: np.array
ydata: np.array
zorder: any number
Additional kwargs: hold = [True|False] overrides default hold state
- delaxes(*args)
- delaxes(ax) - remove ax from the current figure. If ax doesn't
exist an error will be raised.
delaxes(): delete the current axes
- disconnect(cid)
- disconnect callback id cid
- draw()
- redraw the current figure
- errorbar(*args, **kwargs)
- ERRORBAR(x, y, yerr=None, xerr=None,
fmt='b-', ecolor=None, elinewidth=None, capsize=3,
barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False)
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
xerr and yerr may be any of:
a rank-0, Nx1 Numpy array - symmetric errorbars +/- value
an N-element list or tuple - symmetric errorbars +/- value
a rank-1, Nx2 Numpy array - asymmetric errorbars -column1/+column2
Alternatively, x, y, xerr, and yerr can all be scalars, which
plots a single error bar at x, y.
fmt is the plot format symbol for y. if fmt is None, just
plot the errorbars with no line symbols. This can be useful
for creating a bar plot with errorbars
ecolor is a matplotlib color arg which gives the color the
errorbar lines; if None, use the marker color.
elinewidth is the linewidth of the errorbar lines;
if None, use the linewidth.
capsize is the size of the error bar caps in points
barsabove, if True, will plot the errorbars above the plot symbols
- default is below
lolims, uplims, xlolims, xuplims: 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 of the same type as xerr and yerr.
kwargs are passed on to the plot command for the markers.
So you can add additional key=value pairs to control the
errorbar 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)
mfc, mec, ms and mew are aliases for the longer property
names, markerfacecolor, markeredgecolor, markersize and
markeredgewith.
valid kwargs for the marker properties are
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: unknown
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color or c: any matplotlib color
contains: unknown
dash_capstyle: ['butt' | 'round' | 'projecting']
dash_joinstyle: ['miter' | 'round' | 'bevel']
dashes: sequence of on/off ink in points
data: (np.array xdata, np.array ydata)
figure: a matplotlib.figure.Figure instance
label: any string
linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw: float value in points
lod: [True | False]
marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec: any matplotlib color
markeredgewidth or mew: float value in points
markerfacecolor or mfc: any matplotlib color
markersize or ms: float
picker: unknown
pickradius: unknown
solid_capstyle: ['butt' | 'round' | 'projecting']
solid_joinstyle: ['miter' | 'round' | 'bevel']
transform: a matplotlib.transforms.Transform instance
visible: [True | False]
xdata: np.array
ydata: np.array
zorder: any number
Return value is a length 3 tuple. The first element is the
Line2D instance for the y symbol lines. The second element is
a list of error bar cap lines, the third element is a list of
line collections for the horizontal and vertical error ranges
Additional kwargs: hold = [True|False] overrides default hold state
- figimage(*args, **kwargs)
- FIGIMAGE(X) # add non-resampled array to figure
FIGIMAGE(X, xo, yo) # with pixel offsets
FIGIMAGE(X, **kwargs) # control interpolation ,scaling, etc
Add a nonresampled figure to the figure from array X. xo and yo are
offsets in pixels
X must be a float array
If X is MxN, assume luminance (grayscale)
If X is MxNx3, assume RGB
If X is MxNx4, assume RGBA
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to
the rc image.cmap valuex
* norm is a matplotlib.colors.Normalize instance; default is
normalization(). This scales luminance -> 0-1
* vmin and 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 = 1.0 : the alpha blending value
* origin is either 'upper' or 'lower', which 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
This complements the axes image (Axes.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 size [0,1,0,1].
A image.FigureImage instance is returned.
Addition kwargs: hold = [True|False] overrides default hold state
- figlegend(handles, labels, loc, **kwargs)
- Place a legend in the figure. Labels are a sequence of
strings, handles is a sequence of line or patch instances, and
loc can be a string r an integer specifying the legend
location
USAGE:
legend( (line1, line2, line3),
('label1', 'label2', 'label3'),
'upper right')
See help(legend) for information about the location codes
A matplotlib.legend.Legend instance is returned
- figtext(*args, **kwargs)
- Add text to figure at location x,y (relative 0-1 coords) See
the help for Axis text for the meaning of the other arguments
kwargs control the Text properties:
alpha: float
animated: [True | False]
axes: an axes instance
backgroundcolor: any matplotlib color
bbox: rectangle prop dict plus key 'pad' which is a pad in points
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color: any matplotlib color
contains: unknown
family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure: a matplotlib.figure.Figure instance
fontproperties: a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
label: any string
linespacing: float
lod: [True | False]
multialignment: ['left' | 'right' | 'center' ]
name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
picker: [None|float|boolean|callable]
position: (x,y)
rotation: [ angle in degrees 'vertical' | 'horizontal'
size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle: [ 'normal' | 'italic' | 'oblique']
text: string or anything printable with '%s' conversion
transform: a matplotlib.transform transformation instance
variant: [ 'normal' | 'small-caps' ]
verticalalignment or va: [ 'center' | 'top' | 'bottom' | 'baseline' ]
visible: [True | False]
weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x: float
y: float
zorder: any number
- figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, FigureClass=<class 'matplotlib.figure.Figure'>, **kwargs)
- figure(num = None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
Create a new figure and return a handle to it. If num=None, the figure
number will be incremented and a new figure will be created. The returned
figure objects have a .number attribute holding this number.
If num is an integer, and figure(num) already exists, make it
active and return the handle to it. If figure(num) does not exist
it will be created. Numbering starts at 1, matlab style
figure(1)
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.
kwargs:
figsize - width x height in inches; defaults to rc figure.figsize
dpi - resolution; defaults to rc figure.dpi
facecolor - the background color; defaults to rc figure.facecolor
edgecolor - the border color; defaults to rc figure.edgecolor
rcParams gives the default values from the matplotlibrc file
FigureClass is a Figure or derived class that will be passed on to
new_figure_manager in the backends which allows you to hook custom
Figureclasses into the pylab interface. Additional kwargs will be
passed on to your figure init function
- fill(*args, **kwargs)
- FILL(*args, **kwargs)
plot filled polygons. *args is a variable length argument, allowing
for multiple x,y pairs with an optional color format string; see plot
for details on the argument parsing. For example, all of the
following are legal, assuming ax is an Axes instance:
ax.fill(x,y) # plot polygon with vertices at x,y
ax.fill(x,y, 'b' ) # plot polygon with vertices at x,y in blue
An arbitrary number of x, y, color groups can be specified, as in
ax.fill(x1, y1, 'g', x2, y2, 'r')
Return value is a list of patches that were added
The same color strings that plot supports are supported by the fill
format string.
If you would like to fill below a curve, eg shade a region
between 0 and y along x, use mlab.poly_between, eg
xs, ys = poly_between(x, 0, y)
axes.fill(xs, ys, facecolor='red', alpha=0.5)
See examples/fill_between.py for more examples.
kw
|