| |
- matplotlib.artist.Artist
-
- Axes
-
- PolarAxes
- SubplotBase
-
- PolarSubplot(SubplotBase, PolarAxes)
- Subplot(SubplotBase, Axes)
class Axes(matplotlib.artist.Artist) |
|
Emulate matlab's (TM) axes command, creating axes with
Axes(position=[left, bottom, width, height])
where all the arguments are fractions in [0,1] which specify the
fraction of the total figure window.
axisbg is the color of the axis background |
|
Methods defined here:
- __init__(self, fig, rect, axisbg=None, frameon=True)
- add_artist(self, a)
- Add any artist to the axes
- add_collection(self, collection)
- add a Collection instance to Axes
- add_line(self, l)
- Add a line to the list of plot lines
- add_patch(self, p)
- Add a line to the list of plot lines
- add_table(self, tab)
- Add a table instance to the list of axes tables
- autoscale_view(self)
- autoscale the view limits using the data limits
- axhline(self, y=0, xmin=0, xmax=1, **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)
- axhspan(self, ymin, ymax, xmin=0, xmax=1, **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)
- axvline(self, x=0, ymin=0, ymax=1, **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)
- axvspan(self, xmin, xmax, ymin=0, ymax=1, **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)
- bar(self, left, height, width=0.80000000000000004, bottom=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BAR(left, height, width=0.8, bottom=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
Make a bar plot with rectangles at
left, left+width, 0, height
left and height are Numeric arrays.
Return value is a list of Rectangle patch instances
BAR(left, height, width, bottom,
color, yerr, xerr, capsize, yoff)
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
color specifies the color of the bar
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, width and bottom can be either
scalars or len(x) sequences
This enables you to use bar as the basis for stacked bar
charts, or candlestick plots
- barh(self, x, y, height=0.80000000000000004, left=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BARH(x, y, height=0.8, left=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
BARH(x, y)
The y values give the heights of the center of the bars. The
x values give the length of the bars.
Return value is a list of Rectangle patch instances
Optional arguments
height - the height (thickness) of the bar
left - the x coordinate of the left side of the bar
color specifies the color of the bar
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, height and left can be either
scalars or len(x) sequences
- cla(self)
- Clear the current axes
- clear(self)
- clear the axes
- cohere(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- COHERE(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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.
Returns the tuple Cxy, freqs
Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- connect(self, s, func)
- contour(self, z, x=None, y=None, levels=None, colors=None, linewidths=None, alpha=1.0, fmt='%1.3f')
- CONTOUR(z, x = None, y = None, levels = None, colors = None)
plots contour lines of an image z
z is a 2D array of image values
x and y are 2D arrays with coordinates of z values in the
two directions. x and y do not need to be evenly spaced but must
be of the same shape as z
levels can be a list of level values or the number of levels to be
plotted. If levels == None, a default number of 7 evenly spaced
levels is plotted.
colors is one of these:
- 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 default color for lines.color in
.matplotlibrc is used.
linewidths is one of:
- 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
reg is a 2D region number array with the same dimensions as x and
y. The values of reg should be positive region numbers, and zero fro
zones wich do not exist.
triangle - triangulation array - must be the same shape as reg
alpha : the default transparency of contour lines
fmt is a format string for adding a label to each collection.
Currently this is useful for auto-legending and may be useful down
the road for legend labeling
More information on reg and triangle arrays is in _contour.c
Return value is levels, collections where levels is a list of contour
levels used and collections is a list of
matplotlib.collections.LineCollection instances
- csd(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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*log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- disconnect(self, cid)
- disconnect from the Axes event.
- draw(self, renderer)
- Draw everything (plot lines, axes, labels)
- errorbar(self, x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False, **kwargs)
- ERRORBAR(x, y, yerr=None, xerr=None,
fmt='b-', ecolor=None, capsize=3, barsabove=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.
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
kwargs are passed on to the plot command for the markers
Return value is a length 2 tuple. The first element is a list of
y symbol lines. The second element is a list of error bar lines.
- fill(self, *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 a is the Axis 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.
The kwargs that are can be used to set line properties (any
property that has a set_* method). You can use this to set edge
color, face color, etc.
- format_coord(self, x, y)
- return a format string formatting the x, y coord
- format_xdata(self, x)
- Return x string formatted. This function will use the attribute
self.fmt_xdata if it is callable, else will fall back on the xaxis
major formatter
- format_ydata(self, y)
- Return y string formatted. This function will use the attribute
self.fmt_ydata if it is callable, else will fall back on the yaxis
major formatter
- get_axis_bgcolor(self)
- Return the axis background color
- get_child_artists(self)
- get_frame(self)
- Return the axes Rectangle frame
- get_images(self)
- return a list of Axes images contained by the Axes
- get_legend(self)
- Return the Legend instance, or None if no legend is defined
- get_lines(self)
- Return a list of lines contained by the Axes
- get_position(self)
- Return the axes rectangle left, bottom, width, height
- get_xaxis(self)
- Return the XAxis instance
- get_xgridlines(self)
- Get the x grid lines as a list of Line2D instances
- get_xlim(self)
- Get the x axis range [xmin, xmax]
- get_xscale(self)
- return the xaxis scale string: log or linear
- get_xticklabels(self)
- Get the xtick labels as a list of Text instances
- get_xticklines(self)
- Get the xtick lines as a list of Line2D instances
- get_xticks(self)
- Return the x ticks as a list of locations
- get_yaxis(self)
- Return the YAxis instance
- get_ygridlines(self)
- Get the y grid lines as a list of Line2D instances
- get_ylim(self)
- Get the y axis range [ymin, ymax]
- get_yscale(self)
- return the yaxis scale string: log or linear
- get_yticklabels(self)
- Get the ytick labels as a list of Text instances
- get_yticklines(self)
- Get the ytick lines as a list of Line2D instances
- get_yticks(self)
- Return the y ticks as a list of locations
- grid(self, b=None)
- Set the axes grids on or off; b is a boolean
if b is None, toggle the grid state
- has_data(self)
- return true if any artists have been added to axes
- hist(self, x, bins=10, normed=0, bottom=0)
- HIST(x, bins=10, normed=0, bottom=0)
Compute the histogram of x. bins is either an integer number of
bins or a sequence giving the bins. x are the data to be binned.
The return values is (n, bins, patches)
If normed is true, the first element of the return tuple will be the
counts normalized to form a probability distribtion, ie,
n/(len(x)*dbin)
- hlines(self, y, xmin, xmax, fmt='k-')
- HLINES(y, xmin, xmax, fmt='k-')
plot horizontal lines at each y from xmin to xmax. xmin or xmax can
be scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the widths of the lines are
determined by xmin and xmax
Returns a list of line instances that were added
- hold(self, b=None)
- HOLD(b=None)
Set the hold state. If hold is None (default), toggle the
hold state. Else set the hold state to boolean value b.
Eg
hold() # toggle hold
hold(True) # hold is on
hold(False) # hold is off
- imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
- IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
IMSHOW(X) - plot image X to current axes, resampling to scale to axes
size (X may be numarray/Numeric array or PIL image)
IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
colormapping etc. See below for details
Display the image in X to current axes. X may be a float array or a
PIL image. If X is a float array, X can have the following shapes
MxN : luminance (grayscale)
MxNx3 : RGB
MxNx4 : RGBA
A matplotlib.image.AxesImage instance is returned
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to rc
image.cmap value (Ignored when X has RGB(A) information)
* aspect is one of: free or preserve. if None, default to rc
image.aspect value
* interpolation is one of: bicubic bilinear blackman100 blackman256
blackman64 nearest sinc144 sinc256 sinc64 spline16 or spline36.
If None, default to rc image.interpolation
* norm is a matplotlib.colors.normalize instance; default is
normalization(). This scales luminance -> 0-1 (Ignored when X is
PIL image).
* 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. If None, default to rc image.origin
* extent is a data xmin, xmax, ymin, ymax for making image plots
registered with data plots. Default is the image dimensions
in pixels
- in_axes(self, xwin, ywin)
- return True is the point xwin, ywin (display coords) are in the Axes
- ishold(self)
- return the HOLD status of the axes
- legend(self, *args, **kwargs)
- LEGEND(*args, **kwargs)
Place a legend on the current axes at location loc. Labels are a
sequence of strings and loc can be a string or an integer specifying
the legend location
USAGE:
Make a legend with existing lines
>>> legend()
legend by itself will try and build a legend using the label
property of the lines/patches/collections. You can set the label of
a line by doing plot(x, y, label='my data') or line.set_label('my
data')
# automatically generate the legend from labels
legend( ('label1', 'label2', 'label3') )
# Make a legend for a list of lines and labels
legend( (line1, line2, line3), ('label1', 'label2', 'label3') )
# Make a legend at a given location, using a location argument
# legend( LABELS, LOC ) or
# legend( LINES, LABELS, LOC )
legend( ('label1', 'label2', 'label3'), loc='upper left')
legend( (line1, line2, line3), ('label1', 'label2', 'label3'), loc=2)
The location codes are
'best' : 0, (currently not supported, defaults to upper right)
'upper right' : 1, (default)
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10,
If none of these are suitable, loc can be a 2-tuple giving x,y
in axes coords, ie,
loc = 0, 1 is left top
loc = 0.5, 0.5 is center, center
and so on. The following kwargs are supported
numpoints = 4 # the number of points in the legend line
prop = FontProperties('smaller') # the font properties
pad = 0.2 # the fractional whitespace inside the legend border
# The kwarg dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
handlelen = 0.05 # the length of the legend lines
handletextsep = 0.02 # the space between the legend line and legend text
axespad = 0.02 # the border between the axes and legend edge
- loglog(self, *args, **kwargs)
- LOGLOG(*args, **kwargs)
Make a loglog plot with log scaling on the a and y axis. The args
to semilog x are the same as the args to plot. See help plot for
more info.
Optional keyword args supported are any of the kwargs
supported by plot or set_xscale or set_yscale. Notable, for
log scaling:
* basex: base of the x logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
* basey: base of the y logarithm
* subsy: the location of the minor yticks; None defaults to range(2,basey)
- panx(self, numsteps)
- Pan the x axis numsteps (plus pan right, minus pan left)
- pany(self, numsteps)
- Pan the x axis numsteps (plus pan up, minus pan down)
- pcolor(self, *args, **kwargs)
- PCOLOR(*args, **kwargs)
Function signatures
PCOLOR(C) - make a pseudocolor plot of matrix C
PCOLOR(X, Y, C) - a pseudo color plot of C on the matrices X and Y
PCOLOR(C, **kwargs) - Use keywork args to control colormapping and
scaling; see below
Optional keywork args are shown with their defaults below (you must
use kwargs for these):
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to cm.jet
* norm = normalize() : matplotlib.colors.normalize is used to scale
luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. If you pass a norm
instance, vmin and vmax will be None
* shading = 'flat' : or 'faceted'. If 'faceted', a black grid is
drawn around each rectangle; if 'flat', edge colors are same as
face colors
* alpha=1.0 : the alpha blending value
Return value is a matplotlib.collections.PatchCollection
object
Grid Orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for
x and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and pylab. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows and
numcols of Z
- pcolor_classic(self, *args, **kwargs)
- PCOLOR_CLASSIC(self, *args, **kwargs)
Function signatures
pcolor(C) - make a pseudocolor plot of matrix C
pcolor(X, Y, C) - a pseudo color plot of C on the matrices X and Y
pcolor(C, cmap=cm.jet) - make a pseudocolor plot of matrix C using
rectangle patches using a colormap jet. Colormaps are avalible
in matplotlib.cm. You must pass this as a kwarg.
pcolor(C, norm=normalize()) - the normalization function used
` to scale your color data to 0-1. must be passed as a kwarg.
pcolor(C, alpha=0.5) - set the alpha of the pseudocolor plot.
Must be used as a kwarg
Shading:
The optional keyword arg shading ('flat' or 'faceted') will
determine whether a black grid is drawn around each pcolor square.
Default 'faceteted' e.g., pcolor(C, shading='flat') pcolor(X, Y,
C, shading='faceted')
Return value is a list of patch objects.
Grid orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for x
and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and matplotlib. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows
and numcols of Z
- plot(self, *args, **kwargs)
- PLOT(*args, **kwargs)
Plot lines and/or markers to the Axes. *args is a variable length
argument, allowing for multiple x,y pairs with an optional format
string. For example, each of the following is legal
plot(x,y) # plot x and y using the default line style and color
plot(x,y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of x, y, fmt groups can be specified, as in
a.plot(x1, y1, 'g^', x2, y2, 'g-')
Return value is a list of lines that were added.
The following line styles are supported:
- : solid line
-- : dashed line
-. : dash-dot line
: : dotted line
. : points
, : pixels
o : circle symbols
^ : triangle up symbols
v : triangle down symbols
< : triangle left symbols
> : triangle right symbols
s : square symbols
+ : plus symbols
x : cross symbols
D : diamond symbols
d : thin diamond symbols
1 : tripod down symbols
2 : tripod up symbols
3 : tripod left symbols
4 : tripod right symbols
h : hexagon symbols
H : rotated hexagon symbols
p : pentagon symbols
| : vertical line symbols
_ : horizontal line symbols
steps : use gnuplot style 'steps' # kwarg only
The following color strings are supported
b : blue
g : green
r : red
c : cyan
m : magenta
y : yellow
k : black
w : white
Line styles and colors are combined in a single format string, as in
'bo' for blue circles.
The **kwargs can be used to set line properties (any property that has
a set_* method). You can use this to set a line label (for auto
legends), linewidth, anitialising, marker face color, etc. Here is an
example:
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs apply
to all those lines, eg
plot(x1, y1, x2, y2, antialising=False)
Neither line will be antialiased.
- plot_date(self, d, y, fmt='bo', tz=None, **kwargs)
- PLOT_DATE(d, y, converter, fmt='bo', tz=None, **kwargs)
d is a sequence of dates represented as float days since
0001-01-01 UTC and y are the y values at those dates. fmt is
a plot format string. kwargs are passed on to plot. See plot
for more information.
See matplotlib.dates for helper functions date2num, num2date
and drange for help on creating the required floating point dates
tz is the timezone - defaults to rc value
- psd(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
The power spectral density by Welches average periodogram method. The
vector x is divided into NFFT length segments. Each segment is
detrended by function detrend and windowed by function window.
noperlap gives the length of the overlap between segments. The
absolute(fft(segment))**2 of each segment are averaged to compute Pxx,
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
NFFT is the length of the fft segment; must be a power of 2
Fs is the sampling frequency.
detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
For plotting, the power is plotted as 10*log10(pxx)) for decibels,
though pxx itself is returned
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, **kwargs)
- SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0)
Supported function signatures:
SCATTER(x, y) - make a scatter plot of x vs y
SCATTER(x, y, s) - make a scatter plot of x vs y with size in area
given by s
SCATTER(x, y, s, c) - make a scatter plot of x vs y with size in area
given by s and colors given by c
SCATTER(x, y, s, c, **kwargs) - control colormapping and scaling
with keyword args; see below
Make a scatter plot of x versus y. s is a size in points^2 a scalar
or an array of the same length as x or y. c is a color and can be a
single color format string or an length(x) array of intensities which
will be mapped by the matplotlib.colors.colormap instance cmap
The marker can be one of
's' : square
'o' : circle
'^' : triangle up
'>' : triangle right
'v' : triangle down
'<' : triangle left
'd' : diamond
'p' : pentagram
'h' : hexagon
'8' : octagon
s is a size argument in points squared.
Other keyword args; the color mapping and normalization arguments will
on be used if c is an array of floats
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to rc image.cmap
* norm = normalize() : matplotlib.colors.normalize is used to
scale luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. Note if you pass a norm
instance, your settings for vmin and vmax will be ignored
* alpha =1.0 : the alpha value for the patches
- scatter_classic(self, x, y, s=None, c='b')
- SCATTER_CLASSIC(x, y, s=None, c='b')
Make a scatter plot of x versus y. s is a size (in data coords) and
can be either a scalar or an array of the same length as x or y. c is
a color and can be a single color format string or an length(x) array
of intensities which will be mapped by the colormap jet.
If size is None a default size will be used
- semilogx(self, *args, **kwargs)
- SEMILOGX(*args, **kwargs)
Make a semilog plot with log scaling on the x axis. The args to
semilog x are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_xscale. Notable, for log scaling:
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to
range(2,basex)
- semilogy(self, *args, **kwargs)
- SEMILOGY(*args, **kwargs):
Make a semilog plot with log scaling on the y axis. The args to
semilogy are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_yscale. Notable, for log scaling:
* basey: base of the logarithm
* subsy: the location of the minor ticks; None defaults to
range(2,basey)
- set_axis_bgcolor(self, color)
- set the axes bacground color
- set_axis_off(self)
- turn off the axis
- set_axis_on(self)
- turn on the axis
- set_frame_on(self, b)
- Set whether the axes rectangle patch is drawn with boolean b
- set_image_extent(self, xmin, xmax, ymin, ymax)
- Set the data units of the image. This is useful if you want to
plot other things over the image, eg, lines or scatter
- set_position(self, pos)
- Set the axes position with pos = [left, bottom, width, height]
in relative 0,1 coords
- set_title(self, label, fontdict=None, **kwargs)
- SET_TITLE(label, fontdict=None, **kwargs):
Set the title for the xaxis. See the text docstring for information
of how override and the optional args work
- set_xlabel(self, xlabel, fontdict=None, **kwargs)
- SET_XLABEL(xlabel, fontdict=None, **kwargs)
Set the label for the xaxis. See the text docstring for information
of how override and the optional args work.
- set_xlim(self, v, emit=True)
- SET_XLIM(v, emit=True)
Set the limits for the xaxis; v = [xmin, xmax]
If emit is false, do not trigger an event
- set_xscale(self, value, basex=10, subsx=None)
- SET_XSCALE(value, basex=10, subsx=None)
Set the xscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
- set_xticklabels(self, labels, fontdict=None, **kwargs)
- SET_XTICKLABELS(labels, fontdict=None, **kwargs)
Set the xtick labels with list of strings labels Return a list of axis
text instances
- set_xticks(self, ticks)
- Set the x ticks with list of ticks
- set_ylabel(self, ylabel, fontdict=None, **kwargs)
- SET_YLABEL(ylabel, fontdict=None, **kwargs)
Set the label for the yaxis
Defaults override is
override = {
'verticalalignment' : 'center',
'horizontalalignment' : 'right',
'rotation'='vertical' : }
See the text doctstring for information of how override and
the optional args work
- set_ylim(self, v, emit=True)
- SET_YLIM(v, emit=True)
Set the limits for the xaxis; v = [ymin, ymax]. If emit is false, do
not trigger an event.
- set_yscale(self, value, basey=10, subsy=None)
- SET_YSCALE(value, basey=10, subsy=None)
Set the yscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basey: base of the logarithm
* subsy: the location of the minor ticks; None are the default
range(2,basex)
- set_yticklabels(self, labels, fontdict=None, **kwargs)
- SET_YTICKLABELS(labels, fontdict=None, **kwargs)
Set the ytick labels with list of strings labels. Return a list of
Text instances
- set_yticks(self, ticks)
- Set the y ticks with list of ticks
- specgram(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=128, cmap=None, xextent=None)
- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
Compute a spectrogram of data in x. Data are split into NFFT length
segements and the PSD of each section is computed. The windowing
function window is applied to each segment, and the amount of overlap
of each segment is specified with noverlap.
* cmap is a colormap; if None use default determined by rc
* xextent is the image extent in the xaxes xextent=xmin, xmax -
default 0, max(bins), 0, max(freqs) where bins is the return
value from matplotlib.mlab.specgram
* See help(psd) for information on the other keyword arguments.
Return value is (Pxx, freqs, bins, im), where
bins are the time points the spectrogram is calculated over
freqs is an array of frequencies
Pxx is a len(times) x len(freqs) array of power
im is a matplotlib.image.AxesImage.
- spy(self, Z, marker='s', markersize=10, **kwargs)
- SPY(Z, **kwrags) plots the sparsity pattern of the matrix S
using plot markers.
kwargs give the marker properties - see help(plot) for more
information on marker properties
The line handles are returned
- spy2(self, Z)
- SPY2(Z) plots the sparsity pattern of the matrix S as an image
The image instance is returned
- stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
- STEM(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
A stem plot plots vertical lines (using linefmt) at each x location
from the baseline to y, and places a marker there using markerfmt. A
horizontal line at 0 is is plotted using basefmt
Return value is (markerline, stemlines, baseline) .
See
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html
for details and examples/stem_plot.py for a demo.
- table(self, cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None)
- TABLE(cellText=None, cellColours=None,
cellLoc='right', colWidths=None,
rowLabels=None, rowColours=None, rowLoc='left',
colLabels=None, colColours=None, colLoc='center',
loc='bottom', bbox=None):
Add a table to the current axes. Returns a table instance. For
finer grained control over tables, use the Table class and add it
to the axes with add_table.
Thanks to John Gill for providing the class and table.
- text(self, x, y, s, fontdict=None, **kwargs)
- TEXT(x, y, s, fontdict=None, **kwargs)
Add text in string s to axis at location x,y (data coords)
fontdict is a dictionary to override the default text properties.
If fontdict is None, the defaults are determined by your rc
parameters.
Individual keyword arguemnts can be used to override any given
parameter
text(x, y, s, fontsize=12)
The default transform specifies that text is in data coords,
alternatively, you can specify text in axis coords (0,0 lower left and
1,1 upper right). The example below places text in the center of the
axes
text(0.5, 0.5,'matplotlib',
horizontalalignment='center',
verticalalignment='center',
transform = ax.transAxes,
)
- update_datalim(self, xys)
- Update the data lim bbox with seq of xy tups
- vlines(self, x, ymin, ymax, color='k')
- VLINES(x, ymin, ymax, color='k')
Plot vertical lines at each x from ymin to ymax. ymin or ymax can be
scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the heights of the lines are
determined by ymin and ymax
Returns a list of lines that were added
- zoomx(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
- zoomy(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
Methods inherited from matplotlib.artist.Artist:
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_clip_on(self)
- Return whether artist uses clipping
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
|
class PolarAxes(Axes) |
|
Make a PolarAxes. The rectangular bounding box of the axes is given by
PolarAxes(position=[left, bottom, width, height])
where all the arguments are fractions in [0,1] which specify the
fraction of the total figure window.
axisbg is the color of the axis background
Attributes:
thetagridlines : a list of Line2D for the theta grids
rgridlines : a list of Line2D for the radial grids
thetagridlabels : a list of Text for the theta grid labels
rgridlabels : a list of Text for the theta grid labels |
|
- Method resolution order:
- PolarAxes
- Axes
- matplotlib.artist.Artist
Methods defined here:
- __init__(self, *args, **kwarg)
- autoscale_view(self)
- cla(self)
- Clear the current axes
- draw(self, renderer)
- format_coord(self, theta, r)
- return a format string formatting the coordinate
- get_rmax(self)
- get the maximum radius in the view limits dimension
- grid(self, b)
- Set the axes grids on or off; b is a boolean
- has_data(self)
- return true if any artists have been added to axes
- set_rgrids(self, radii, labels=None, angle=22.5, **kwargs)
- set the radial locations and labels of the r grids
The labels will appear at radial distances radii at angle
labels, if not None, is a len(radii) list of strings of the
labels to use at each angle.
if labels is None, the self.rformatter will be used
Return value is a list of lines, labels where the lines are
matplotlib.Line2D instances and the labels are matplotlib.Text
instances
- set_thetagrids(self, angles, labels=None, fmt='%d', frac=1.1000000000000001, **kwargs)
- set the angles at which to place the theta grids (these
gridlines are equal along the theta dimension). angles is in
degrees
labels, if not None, is a len(angles) list of strings of the
labels to use at each angle.
if labels is None, the labels with be fmt%angle
frac is the fraction of the polar axes radius at which to
place the label (1 is the edge).Eg 1.05 isd outside the axes
and 0.95 is inside the axes
kwargs are optional text properties for the labels
Return value is a list of lines, labels where the lines are
matplotlib.Line2D instances and the labels are matplotlib.Text
instances
- set_xlabel(self, xlabel, fontdict=None, **kwargs)
- xlabel not implemented
- set_ylabel(self, ylabel, fontdict=None, **kwargs)
- ylabel not implemented
Data and other attributes defined here:
- RESOLUTION = 200
Methods inherited from Axes:
- add_artist(self, a)
- Add any artist to the axes
- add_collection(self, collection)
- add a Collection instance to Axes
- add_line(self, l)
- Add a line to the list of plot lines
- add_patch(self, p)
- Add a line to the list of plot lines
- add_table(self, tab)
- Add a table instance to the list of axes tables
- axhline(self, y=0, xmin=0, xmax=1, **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)
- axhspan(self, ymin, ymax, xmin=0, xmax=1, **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)
- axvline(self, x=0, ymin=0, ymax=1, **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)
- axvspan(self, xmin, xmax, ymin=0, ymax=1, **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)
- bar(self, left, height, width=0.80000000000000004, bottom=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BAR(left, height, width=0.8, bottom=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
Make a bar plot with rectangles at
left, left+width, 0, height
left and height are Numeric arrays.
Return value is a list of Rectangle patch instances
BAR(left, height, width, bottom,
color, yerr, xerr, capsize, yoff)
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
color specifies the color of the bar
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, width and bottom can be either
scalars or len(x) sequences
This enables you to use bar as the basis for stacked bar
charts, or candlestick plots
- barh(self, x, y, height=0.80000000000000004, left=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BARH(x, y, height=0.8, left=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
BARH(x, y)
The y values give the heights of the center of the bars. The
x values give the length of the bars.
Return value is a list of Rectangle patch instances
Optional arguments
height - the height (thickness) of the bar
left - the x coordinate of the left side of the bar
color specifies the color of the bar
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, height and left can be either
scalars or len(x) sequences
- clear(self)
- clear the axes
- cohere(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- COHERE(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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.
Returns the tuple Cxy, freqs
Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- connect(self, s, func)
- contour(self, z, x=None, y=None, levels=None, colors=None, linewidths=None, alpha=1.0, fmt='%1.3f')
- CONTOUR(z, x = None, y = None, levels = None, colors = None)
plots contour lines of an image z
z is a 2D array of image values
x and y are 2D arrays with coordinates of z values in the
two directions. x and y do not need to be evenly spaced but must
be of the same shape as z
levels can be a list of level values or the number of levels to be
plotted. If levels == None, a default number of 7 evenly spaced
levels is plotted.
colors is one of these:
- 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 default color for lines.color in
.matplotlibrc is used.
linewidths is one of:
- 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
reg is a 2D region number array with the same dimensions as x and
y. The values of reg should be positive region numbers, and zero fro
zones wich do not exist.
triangle - triangulation array - must be the same shape as reg
alpha : the default transparency of contour lines
fmt is a format string for adding a label to each collection.
Currently this is useful for auto-legending and may be useful down
the road for legend labeling
More information on reg and triangle arrays is in _contour.c
Return value is levels, collections where levels is a list of contour
levels used and collections is a list of
matplotlib.collections.LineCollection instances
- csd(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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*log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- disconnect(self, cid)
- disconnect from the Axes event.
- errorbar(self, x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False, **kwargs)
- ERRORBAR(x, y, yerr=None, xerr=None,
fmt='b-', ecolor=None, capsize=3, barsabove=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.
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
kwargs are passed on to the plot command for the markers
Return value is a length 2 tuple. The first element is a list of
y symbol lines. The second element is a list of error bar lines.
- fill(self, *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 a is the Axis 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.
The kwargs that are can be used to set line properties (any
property that has a set_* method). You can use this to set edge
color, face color, etc.
- format_xdata(self, x)
- Return x string formatted. This function will use the attribute
self.fmt_xdata if it is callable, else will fall back on the xaxis
major formatter
- format_ydata(self, y)
- Return y string formatted. This function will use the attribute
self.fmt_ydata if it is callable, else will fall back on the yaxis
major formatter
- get_axis_bgcolor(self)
- Return the axis background color
- get_child_artists(self)
- get_frame(self)
- Return the axes Rectangle frame
- get_images(self)
- return a list of Axes images contained by the Axes
- get_legend(self)
- Return the Legend instance, or None if no legend is defined
- get_lines(self)
- Return a list of lines contained by the Axes
- get_position(self)
- Return the axes rectangle left, bottom, width, height
- get_xaxis(self)
- Return the XAxis instance
- get_xgridlines(self)
- Get the x grid lines as a list of Line2D instances
- get_xlim(self)
- Get the x axis range [xmin, xmax]
- get_xscale(self)
- return the xaxis scale string: log or linear
- get_xticklabels(self)
- Get the xtick labels as a list of Text instances
- get_xticklines(self)
- Get the xtick lines as a list of Line2D instances
- get_xticks(self)
- Return the x ticks as a list of locations
- get_yaxis(self)
- Return the YAxis instance
- get_ygridlines(self)
- Get the y grid lines as a list of Line2D instances
- get_ylim(self)
- Get the y axis range [ymin, ymax]
- get_yscale(self)
- return the yaxis scale string: log or linear
- get_yticklabels(self)
- Get the ytick labels as a list of Text instances
- get_yticklines(self)
- Get the ytick lines as a list of Line2D instances
- get_yticks(self)
- Return the y ticks as a list of locations
- hist(self, x, bins=10, normed=0, bottom=0)
- HIST(x, bins=10, normed=0, bottom=0)
Compute the histogram of x. bins is either an integer number of
bins or a sequence giving the bins. x are the data to be binned.
The return values is (n, bins, patches)
If normed is true, the first element of the return tuple will be the
counts normalized to form a probability distribtion, ie,
n/(len(x)*dbin)
- hlines(self, y, xmin, xmax, fmt='k-')
- HLINES(y, xmin, xmax, fmt='k-')
plot horizontal lines at each y from xmin to xmax. xmin or xmax can
be scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the widths of the lines are
determined by xmin and xmax
Returns a list of line instances that were added
- hold(self, b=None)
- HOLD(b=None)
Set the hold state. If hold is None (default), toggle the
hold state. Else set the hold state to boolean value b.
Eg
hold() # toggle hold
hold(True) # hold is on
hold(False) # hold is off
- imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
- IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
IMSHOW(X) - plot image X to current axes, resampling to scale to axes
size (X may be numarray/Numeric array or PIL image)
IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
colormapping etc. See below for details
Display the image in X to current axes. X may be a float array or a
PIL image. If X is a float array, X can have the following shapes
MxN : luminance (grayscale)
MxNx3 : RGB
MxNx4 : RGBA
A matplotlib.image.AxesImage instance is returned
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to rc
image.cmap value (Ignored when X has RGB(A) information)
* aspect is one of: free or preserve. if None, default to rc
image.aspect value
* interpolation is one of: bicubic bilinear blackman100 blackman256
blackman64 nearest sinc144 sinc256 sinc64 spline16 or spline36.
If None, default to rc image.interpolation
* norm is a matplotlib.colors.normalize instance; default is
normalization(). This scales luminance -> 0-1 (Ignored when X is
PIL image).
* 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. If None, default to rc image.origin
* extent is a data xmin, xmax, ymin, ymax for making image plots
registered with data plots. Default is the image dimensions
in pixels
- in_axes(self, xwin, ywin)
- return True is the point xwin, ywin (display coords) are in the Axes
- ishold(self)
- return the HOLD status of the axes
- legend(self, *args, **kwargs)
- LEGEND(*args, **kwargs)
Place a legend on the current axes at location loc. Labels are a
sequence of strings and loc can be a string or an integer specifying
the legend location
USAGE:
Make a legend with existing lines
>>> legend()
legend by itself will try and build a legend using the label
property of the lines/patches/collections. You can set the label of
a line by doing plot(x, y, label='my data') or line.set_label('my
data')
# automatically generate the legend from labels
legend( ('label1', 'label2', 'label3') )
# Make a legend for a list of lines and labels
legend( (line1, line2, line3), ('label1', 'label2', 'label3') )
# Make a legend at a given location, using a location argument
# legend( LABELS, LOC ) or
# legend( LINES, LABELS, LOC )
legend( ('label1', 'label2', 'label3'), loc='upper left')
legend( (line1, line2, line3), ('label1', 'label2', 'label3'), loc=2)
The location codes are
'best' : 0, (currently not supported, defaults to upper right)
'upper right' : 1, (default)
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10,
If none of these are suitable, loc can be a 2-tuple giving x,y
in axes coords, ie,
loc = 0, 1 is left top
loc = 0.5, 0.5 is center, center
and so on. The following kwargs are supported
numpoints = 4 # the number of points in the legend line
prop = FontProperties('smaller') # the font properties
pad = 0.2 # the fractional whitespace inside the legend border
# The kwarg dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
handlelen = 0.05 # the length of the legend lines
handletextsep = 0.02 # the space between the legend line and legend text
axespad = 0.02 # the border between the axes and legend edge
- loglog(self, *args, **kwargs)
- LOGLOG(*args, **kwargs)
Make a loglog plot with log scaling on the a and y axis. The args
to semilog x are the same as the args to plot. See help plot for
more info.
Optional keyword args supported are any of the kwargs
supported by plot or set_xscale or set_yscale. Notable, for
log scaling:
* basex: base of the x logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
* basey: base of the y logarithm
* subsy: the location of the minor yticks; None defaults to range(2,basey)
- panx(self, numsteps)
- Pan the x axis numsteps (plus pan right, minus pan left)
- pany(self, numsteps)
- Pan the x axis numsteps (plus pan up, minus pan down)
- pcolor(self, *args, **kwargs)
- PCOLOR(*args, **kwargs)
Function signatures
PCOLOR(C) - make a pseudocolor plot of matrix C
PCOLOR(X, Y, C) - a pseudo color plot of C on the matrices X and Y
PCOLOR(C, **kwargs) - Use keywork args to control colormapping and
scaling; see below
Optional keywork args are shown with their defaults below (you must
use kwargs for these):
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to cm.jet
* norm = normalize() : matplotlib.colors.normalize is used to scale
luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. If you pass a norm
instance, vmin and vmax will be None
* shading = 'flat' : or 'faceted'. If 'faceted', a black grid is
drawn around each rectangle; if 'flat', edge colors are same as
face colors
* alpha=1.0 : the alpha blending value
Return value is a matplotlib.collections.PatchCollection
object
Grid Orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for
x and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and pylab. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows and
numcols of Z
- pcolor_classic(self, *args, **kwargs)
- PCOLOR_CLASSIC(self, *args, **kwargs)
Function signatures
pcolor(C) - make a pseudocolor plot of matrix C
pcolor(X, Y, C) - a pseudo color plot of C on the matrices X and Y
pcolor(C, cmap=cm.jet) - make a pseudocolor plot of matrix C using
rectangle patches using a colormap jet. Colormaps are avalible
in matplotlib.cm. You must pass this as a kwarg.
pcolor(C, norm=normalize()) - the normalization function used
` to scale your color data to 0-1. must be passed as a kwarg.
pcolor(C, alpha=0.5) - set the alpha of the pseudocolor plot.
Must be used as a kwarg
Shading:
The optional keyword arg shading ('flat' or 'faceted') will
determine whether a black grid is drawn around each pcolor square.
Default 'faceteted' e.g., pcolor(C, shading='flat') pcolor(X, Y,
C, shading='faceted')
Return value is a list of patch objects.
Grid orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for x
and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and matplotlib. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows
and numcols of Z
- plot(self, *args, **kwargs)
- PLOT(*args, **kwargs)
Plot lines and/or markers to the Axes. *args is a variable length
argument, allowing for multiple x,y pairs with an optional format
string. For example, each of the following is legal
plot(x,y) # plot x and y using the default line style and color
plot(x,y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of x, y, fmt groups can be specified, as in
a.plot(x1, y1, 'g^', x2, y2, 'g-')
Return value is a list of lines that were added.
The following line styles are supported:
- : solid line
-- : dashed line
-. : dash-dot line
: : dotted line
. : points
, : pixels
o : circle symbols
^ : triangle up symbols
v : triangle down symbols
< : triangle left symbols
> : triangle right symbols
s : square symbols
+ : plus symbols
x : cross symbols
D : diamond symbols
d : thin diamond symbols
1 : tripod down symbols
2 : tripod up symbols
3 : tripod left symbols
4 : tripod right symbols
h : hexagon symbols
H : rotated hexagon symbols
p : pentagon symbols
| : vertical line symbols
_ : horizontal line symbols
steps : use gnuplot style 'steps' # kwarg only
The following color strings are supported
b : blue
g : green
r : red
c : cyan
m : magenta
y : yellow
k : black
w : white
Line styles and colors are combined in a single format string, as in
'bo' for blue circles.
The **kwargs can be used to set line properties (any property that has
a set_* method). You can use this to set a line label (for auto
legends), linewidth, anitialising, marker face color, etc. Here is an
example:
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs apply
to all those lines, eg
plot(x1, y1, x2, y2, antialising=False)
Neither line will be antialiased.
- plot_date(self, d, y, fmt='bo', tz=None, **kwargs)
- PLOT_DATE(d, y, converter, fmt='bo', tz=None, **kwargs)
d is a sequence of dates represented as float days since
0001-01-01 UTC and y are the y values at those dates. fmt is
a plot format string. kwargs are passed on to plot. See plot
for more information.
See matplotlib.dates for helper functions date2num, num2date
and drange for help on creating the required floating point dates
tz is the timezone - defaults to rc value
- psd(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
The power spectral density by Welches average periodogram method. The
vector x is divided into NFFT length segments. Each segment is
detrended by function detrend and windowed by function window.
noperlap gives the length of the overlap between segments. The
absolute(fft(segment))**2 of each segment are averaged to compute Pxx,
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
NFFT is the length of the fft segment; must be a power of 2
Fs is the sampling frequency.
detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
For plotting, the power is plotted as 10*log10(pxx)) for decibels,
though pxx itself is returned
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, **kwargs)
- SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0)
Supported function signatures:
SCATTER(x, y) - make a scatter plot of x vs y
SCATTER(x, y, s) - make a scatter plot of x vs y with size in area
given by s
SCATTER(x, y, s, c) - make a scatter plot of x vs y with size in area
given by s and colors given by c
SCATTER(x, y, s, c, **kwargs) - control colormapping and scaling
with keyword args; see below
Make a scatter plot of x versus y. s is a size in points^2 a scalar
or an array of the same length as x or y. c is a color and can be a
single color format string or an length(x) array of intensities which
will be mapped by the matplotlib.colors.colormap instance cmap
The marker can be one of
's' : square
'o' : circle
'^' : triangle up
'>' : triangle right
'v' : triangle down
'<' : triangle left
'd' : diamond
'p' : pentagram
'h' : hexagon
'8' : octagon
s is a size argument in points squared.
Other keyword args; the color mapping and normalization arguments will
on be used if c is an array of floats
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to rc image.cmap
* norm = normalize() : matplotlib.colors.normalize is used to
scale luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. Note if you pass a norm
instance, your settings for vmin and vmax will be ignored
* alpha =1.0 : the alpha value for the patches
- scatter_classic(self, x, y, s=None, c='b')
- SCATTER_CLASSIC(x, y, s=None, c='b')
Make a scatter plot of x versus y. s is a size (in data coords) and
can be either a scalar or an array of the same length as x or y. c is
a color and can be a single color format string or an length(x) array
of intensities which will be mapped by the colormap jet.
If size is None a default size will be used
- semilogx(self, *args, **kwargs)
- SEMILOGX(*args, **kwargs)
Make a semilog plot with log scaling on the x axis. The args to
semilog x are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_xscale. Notable, for log scaling:
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to
range(2,basex)
- semilogy(self, *args, **kwargs)
- SEMILOGY(*args, **kwargs):
Make a semilog plot with log scaling on the y axis. The args to
semilogy are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_yscale. Notable, for log scaling:
* basey: base of the logarithm
* subsy: the location of the minor ticks; None defaults to
range(2,basey)
- set_axis_bgcolor(self, color)
- set the axes bacground color
- set_axis_off(self)
- turn off the axis
- set_axis_on(self)
- turn on the axis
- set_frame_on(self, b)
- Set whether the axes rectangle patch is drawn with boolean b
- set_image_extent(self, xmin, xmax, ymin, ymax)
- Set the data units of the image. This is useful if you want to
plot other things over the image, eg, lines or scatter
- set_position(self, pos)
- Set the axes position with pos = [left, bottom, width, height]
in relative 0,1 coords
- set_title(self, label, fontdict=None, **kwargs)
- SET_TITLE(label, fontdict=None, **kwargs):
Set the title for the xaxis. See the text docstring for information
of how override and the optional args work
- set_xlim(self, v, emit=True)
- SET_XLIM(v, emit=True)
Set the limits for the xaxis; v = [xmin, xmax]
If emit is false, do not trigger an event
- set_xscale(self, value, basex=10, subsx=None)
- SET_XSCALE(value, basex=10, subsx=None)
Set the xscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
- set_xticklabels(self, labels, fontdict=None, **kwargs)
- SET_XTICKLABELS(labels, fontdict=None, **kwargs)
Set the xtick labels with list of strings labels Return a list of axis
text instances
- set_xticks(self, ticks)
- Set the x ticks with list of ticks
- set_ylim(self, v, emit=True)
- SET_YLIM(v, emit=True)
Set the limits for the xaxis; v = [ymin, ymax]. If emit is false, do
not trigger an event.
- set_yscale(self, value, basey=10, subsy=None)
- SET_YSCALE(value, basey=10, subsy=None)
Set the yscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basey: base of the logarithm
* subsy: the location of the minor ticks; None are the default
range(2,basex)
- set_yticklabels(self, labels, fontdict=None, **kwargs)
- SET_YTICKLABELS(labels, fontdict=None, **kwargs)
Set the ytick labels with list of strings labels. Return a list of
Text instances
- set_yticks(self, ticks)
- Set the y ticks with list of ticks
- specgram(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=128, cmap=None, xextent=None)
- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
Compute a spectrogram of data in x. Data are split into NFFT length
segements and the PSD of each section is computed. The windowing
function window is applied to each segment, and the amount of overlap
of each segment is specified with noverlap.
* cmap is a colormap; if None use default determined by rc
* xextent is the image extent in the xaxes xextent=xmin, xmax -
default 0, max(bins), 0, max(freqs) where bins is the return
value from matplotlib.mlab.specgram
* See help(psd) for information on the other keyword arguments.
Return value is (Pxx, freqs, bins, im), where
bins are the time points the spectrogram is calculated over
freqs is an array of frequencies
Pxx is a len(times) x len(freqs) array of power
im is a matplotlib.image.AxesImage.
- spy(self, Z, marker='s', markersize=10, **kwargs)
- SPY(Z, **kwrags) plots the sparsity pattern of the matrix S
using plot markers.
kwargs give the marker properties - see help(plot) for more
information on marker properties
The line handles are returned
- spy2(self, Z)
- SPY2(Z) plots the sparsity pattern of the matrix S as an image
The image instance is returned
- stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
- STEM(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
A stem plot plots vertical lines (using linefmt) at each x location
from the baseline to y, and places a marker there using markerfmt. A
horizontal line at 0 is is plotted using basefmt
Return value is (markerline, stemlines, baseline) .
See
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html
for details and examples/stem_plot.py for a demo.
- table(self, cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None)
- TABLE(cellText=None, cellColours=None,
cellLoc='right', colWidths=None,
rowLabels=None, rowColours=None, rowLoc='left',
colLabels=None, colColours=None, colLoc='center',
loc='bottom', bbox=None):
Add a table to the current axes. Returns a table instance. For
finer grained control over tables, use the Table class and add it
to the axes with add_table.
Thanks to John Gill for providing the class and table.
- text(self, x, y, s, fontdict=None, **kwargs)
- TEXT(x, y, s, fontdict=None, **kwargs)
Add text in string s to axis at location x,y (data coords)
fontdict is a dictionary to override the default text properties.
If fontdict is None, the defaults are determined by your rc
parameters.
Individual keyword arguemnts can be used to override any given
parameter
text(x, y, s, fontsize=12)
The default transform specifies that text is in data coords,
alternatively, you can specify text in axis coords (0,0 lower left and
1,1 upper right). The example below places text in the center of the
axes
text(0.5, 0.5,'matplotlib',
horizontalalignment='center',
verticalalignment='center',
transform = ax.transAxes,
)
- update_datalim(self, xys)
- Update the data lim bbox with seq of xy tups
- vlines(self, x, ymin, ymax, color='k')
- VLINES(x, ymin, ymax, color='k')
Plot vertical lines at each x from ymin to ymax. ymin or ymax can be
scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the heights of the lines are
determined by ymin and ymax
Returns a list of lines that were added
- zoomx(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
- zoomy(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
Methods inherited from matplotlib.artist.Artist:
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_clip_on(self)
- Return whether artist uses clipping
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
|
class PolarSubplot(SubplotBase, PolarAxes) |
|
Create a polar subplot with
PolarSubplot(numRows, numCols, plotNum)
where plotNum=1 is the first plot number and increasing plotNums
fill rows first. max(plotNum)==numRows*numCols
You can leave out the commas if numRows<=numCols<=plotNum<10, as
in
Subplot(211) # 2 rows, 1 column, first (upper) plot |
|
- Method resolution order:
- PolarSubplot
- SubplotBase
- PolarAxes
- Axes
- matplotlib.artist.Artist
Methods defined here:
- __init__(self, fig, *args, **kwargs)
Methods inherited from SubplotBase:
- is_first_col(self)
- is_first_row(self)
- is_last_col(self)
- is_last_row(self)
Methods inherited from PolarAxes:
- autoscale_view(self)
- cla(self)
- Clear the current axes
- draw(self, renderer)
- format_coord(self, theta, r)
- return a format string formatting the coordinate
- get_rmax(self)
- get the maximum radius in the view limits dimension
- grid(self, b)
- Set the axes grids on or off; b is a boolean
- has_data(self)
- return true if any artists have been added to axes
- set_rgrids(self, radii, labels=None, angle=22.5, **kwargs)
- set the radial locations and labels of the r grids
The labels will appear at radial distances radii at angle
labels, if not None, is a len(radii) list of strings of the
labels to use at each angle.
if labels is None, the self.rformatter will be used
Return value is a list of lines, labels where the lines are
matplotlib.Line2D instances and the labels are matplotlib.Text
instances
- set_thetagrids(self, angles, labels=None, fmt='%d', frac=1.1000000000000001, **kwargs)
- set the angles at which to place the theta grids (these
gridlines are equal along the theta dimension). angles is in
degrees
labels, if not None, is a len(angles) list of strings of the
labels to use at each angle.
if labels is None, the labels with be fmt%angle
frac is the fraction of the polar axes radius at which to
place the label (1 is the edge).Eg 1.05 isd outside the axes
and 0.95 is inside the axes
kwargs are optional text properties for the labels
Return value is a list of lines, labels where the lines are
matplotlib.Line2D instances and the labels are matplotlib.Text
instances
- set_xlabel(self, xlabel, fontdict=None, **kwargs)
- xlabel not implemented
- set_ylabel(self, ylabel, fontdict=None, **kwargs)
- ylabel not implemented
Data and other attributes inherited from PolarAxes:
- RESOLUTION = 200
Methods inherited from Axes:
- add_artist(self, a)
- Add any artist to the axes
- add_collection(self, collection)
- add a Collection instance to Axes
- add_line(self, l)
- Add a line to the list of plot lines
- add_patch(self, p)
- Add a line to the list of plot lines
- add_table(self, tab)
- Add a table instance to the list of axes tables
- axhline(self, y=0, xmin=0, xmax=1, **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)
- axhspan(self, ymin, ymax, xmin=0, xmax=1, **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)
- axvline(self, x=0, ymin=0, ymax=1, **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)
- axvspan(self, xmin, xmax, ymin=0, ymax=1, **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)
- bar(self, left, height, width=0.80000000000000004, bottom=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BAR(left, height, width=0.8, bottom=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
Make a bar plot with rectangles at
left, left+width, 0, height
left and height are Numeric arrays.
Return value is a list of Rectangle patch instances
BAR(left, height, width, bottom,
color, yerr, xerr, capsize, yoff)
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
color specifies the color of the bar
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, width and bottom can be either
scalars or len(x) sequences
This enables you to use bar as the basis for stacked bar
charts, or candlestick plots
- barh(self, x, y, height=0.80000000000000004, left=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BARH(x, y, height=0.8, left=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
BARH(x, y)
The y values give the heights of the center of the bars. The
x values give the length of the bars.
Return value is a list of Rectangle patch instances
Optional arguments
height - the height (thickness) of the bar
left - the x coordinate of the left side of the bar
color specifies the color of the bar
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, height and left can be either
scalars or len(x) sequences
- clear(self)
- clear the axes
- cohere(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- COHERE(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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.
Returns the tuple Cxy, freqs
Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- connect(self, s, func)
- contour(self, z, x=None, y=None, levels=None, colors=None, linewidths=None, alpha=1.0, fmt='%1.3f')
- CONTOUR(z, x = None, y = None, levels = None, colors = None)
plots contour lines of an image z
z is a 2D array of image values
x and y are 2D arrays with coordinates of z values in the
two directions. x and y do not need to be evenly spaced but must
be of the same shape as z
levels can be a list of level values or the number of levels to be
plotted. If levels == None, a default number of 7 evenly spaced
levels is plotted.
colors is one of these:
- 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 default color for lines.color in
.matplotlibrc is used.
linewidths is one of:
- 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
reg is a 2D region number array with the same dimensions as x and
y. The values of reg should be positive region numbers, and zero fro
zones wich do not exist.
triangle - triangulation array - must be the same shape as reg
alpha : the default transparency of contour lines
fmt is a format string for adding a label to each collection.
Currently this is useful for auto-legending and may be useful down
the road for legend labeling
More information on reg and triangle arrays is in _contour.c
Return value is levels, collections where levels is a list of contour
levels used and collections is a list of
matplotlib.collections.LineCollection instances
- csd(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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*log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- disconnect(self, cid)
- disconnect from the Axes event.
- errorbar(self, x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False, **kwargs)
- ERRORBAR(x, y, yerr=None, xerr=None,
fmt='b-', ecolor=None, capsize=3, barsabove=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.
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
kwargs are passed on to the plot command for the markers
Return value is a length 2 tuple. The first element is a list of
y symbol lines. The second element is a list of error bar lines.
- fill(self, *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 a is the Axis 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.
The kwargs that are can be used to set line properties (any
property that has a set_* method). You can use this to set edge
color, face color, etc.
- format_xdata(self, x)
- Return x string formatted. This function will use the attribute
self.fmt_xdata if it is callable, else will fall back on the xaxis
major formatter
- format_ydata(self, y)
- Return y string formatted. This function will use the attribute
self.fmt_ydata if it is callable, else will fall back on the yaxis
major formatter
- get_axis_bgcolor(self)
- Return the axis background color
- get_child_artists(self)
- get_frame(self)
- Return the axes Rectangle frame
- get_images(self)
- return a list of Axes images contained by the Axes
- get_legend(self)
- Return the Legend instance, or None if no legend is defined
- get_lines(self)
- Return a list of lines contained by the Axes
- get_position(self)
- Return the axes rectangle left, bottom, width, height
- get_xaxis(self)
- Return the XAxis instance
- get_xgridlines(self)
- Get the x grid lines as a list of Line2D instances
- get_xlim(self)
- Get the x axis range [xmin, xmax]
- get_xscale(self)
- return the xaxis scale string: log or linear
- get_xticklabels(self)
- Get the xtick labels as a list of Text instances
- get_xticklines(self)
- Get the xtick lines as a list of Line2D instances
- get_xticks(self)
- Return the x ticks as a list of locations
- get_yaxis(self)
- Return the YAxis instance
- get_ygridlines(self)
- Get the y grid lines as a list of Line2D instances
- get_ylim(self)
- Get the y axis range [ymin, ymax]
- get_yscale(self)
- return the yaxis scale string: log or linear
- get_yticklabels(self)
- Get the ytick labels as a list of Text instances
- get_yticklines(self)
- Get the ytick lines as a list of Line2D instances
- get_yticks(self)
- Return the y ticks as a list of locations
- hist(self, x, bins=10, normed=0, bottom=0)
- HIST(x, bins=10, normed=0, bottom=0)
Compute the histogram of x. bins is either an integer number of
bins or a sequence giving the bins. x are the data to be binned.
The return values is (n, bins, patches)
If normed is true, the first element of the return tuple will be the
counts normalized to form a probability distribtion, ie,
n/(len(x)*dbin)
- hlines(self, y, xmin, xmax, fmt='k-')
- HLINES(y, xmin, xmax, fmt='k-')
plot horizontal lines at each y from xmin to xmax. xmin or xmax can
be scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the widths of the lines are
determined by xmin and xmax
Returns a list of line instances that were added
- hold(self, b=None)
- HOLD(b=None)
Set the hold state. If hold is None (default), toggle the
hold state. Else set the hold state to boolean value b.
Eg
hold() # toggle hold
hold(True) # hold is on
hold(False) # hold is off
- imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
- IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
IMSHOW(X) - plot image X to current axes, resampling to scale to axes
size (X may be numarray/Numeric array or PIL image)
IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
colormapping etc. See below for details
Display the image in X to current axes. X may be a float array or a
PIL image. If X is a float array, X can have the following shapes
MxN : luminance (grayscale)
MxNx3 : RGB
MxNx4 : RGBA
A matplotlib.image.AxesImage instance is returned
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to rc
image.cmap value (Ignored when X has RGB(A) information)
* aspect is one of: free or preserve. if None, default to rc
image.aspect value
* interpolation is one of: bicubic bilinear blackman100 blackman256
blackman64 nearest sinc144 sinc256 sinc64 spline16 or spline36.
If None, default to rc image.interpolation
* norm is a matplotlib.colors.normalize instance; default is
normalization(). This scales luminance -> 0-1 (Ignored when X is
PIL image).
* 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. If None, default to rc image.origin
* extent is a data xmin, xmax, ymin, ymax for making image plots
registered with data plots. Default is the image dimensions
in pixels
- in_axes(self, xwin, ywin)
- return True is the point xwin, ywin (display coords) are in the Axes
- ishold(self)
- return the HOLD status of the axes
- legend(self, *args, **kwargs)
- LEGEND(*args, **kwargs)
Place a legend on the current axes at location loc. Labels are a
sequence of strings and loc can be a string or an integer specifying
the legend location
USAGE:
Make a legend with existing lines
>>> legend()
legend by itself will try and build a legend using the label
property of the lines/patches/collections. You can set the label of
a line by doing plot(x, y, label='my data') or line.set_label('my
data')
# automatically generate the legend from labels
legend( ('label1', 'label2', 'label3') )
# Make a legend for a list of lines and labels
legend( (line1, line2, line3), ('label1', 'label2', 'label3') )
# Make a legend at a given location, using a location argument
# legend( LABELS, LOC ) or
# legend( LINES, LABELS, LOC )
legend( ('label1', 'label2', 'label3'), loc='upper left')
legend( (line1, line2, line3), ('label1', 'label2', 'label3'), loc=2)
The location codes are
'best' : 0, (currently not supported, defaults to upper right)
'upper right' : 1, (default)
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10,
If none of these are suitable, loc can be a 2-tuple giving x,y
in axes coords, ie,
loc = 0, 1 is left top
loc = 0.5, 0.5 is center, center
and so on. The following kwargs are supported
numpoints = 4 # the number of points in the legend line
prop = FontProperties('smaller') # the font properties
pad = 0.2 # the fractional whitespace inside the legend border
# The kwarg dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
handlelen = 0.05 # the length of the legend lines
handletextsep = 0.02 # the space between the legend line and legend text
axespad = 0.02 # the border between the axes and legend edge
- loglog(self, *args, **kwargs)
- LOGLOG(*args, **kwargs)
Make a loglog plot with log scaling on the a and y axis. The args
to semilog x are the same as the args to plot. See help plot for
more info.
Optional keyword args supported are any of the kwargs
supported by plot or set_xscale or set_yscale. Notable, for
log scaling:
* basex: base of the x logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
* basey: base of the y logarithm
* subsy: the location of the minor yticks; None defaults to range(2,basey)
- panx(self, numsteps)
- Pan the x axis numsteps (plus pan right, minus pan left)
- pany(self, numsteps)
- Pan the x axis numsteps (plus pan up, minus pan down)
- pcolor(self, *args, **kwargs)
- PCOLOR(*args, **kwargs)
Function signatures
PCOLOR(C) - make a pseudocolor plot of matrix C
PCOLOR(X, Y, C) - a pseudo color plot of C on the matrices X and Y
PCOLOR(C, **kwargs) - Use keywork args to control colormapping and
scaling; see below
Optional keywork args are shown with their defaults below (you must
use kwargs for these):
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to cm.jet
* norm = normalize() : matplotlib.colors.normalize is used to scale
luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. If you pass a norm
instance, vmin and vmax will be None
* shading = 'flat' : or 'faceted'. If 'faceted', a black grid is
drawn around each rectangle; if 'flat', edge colors are same as
face colors
* alpha=1.0 : the alpha blending value
Return value is a matplotlib.collections.PatchCollection
object
Grid Orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for
x and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and pylab. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows and
numcols of Z
- pcolor_classic(self, *args, **kwargs)
- PCOLOR_CLASSIC(self, *args, **kwargs)
Function signatures
pcolor(C) - make a pseudocolor plot of matrix C
pcolor(X, Y, C) - a pseudo color plot of C on the matrices X and Y
pcolor(C, cmap=cm.jet) - make a pseudocolor plot of matrix C using
rectangle patches using a colormap jet. Colormaps are avalible
in matplotlib.cm. You must pass this as a kwarg.
pcolor(C, norm=normalize()) - the normalization function used
` to scale your color data to 0-1. must be passed as a kwarg.
pcolor(C, alpha=0.5) - set the alpha of the pseudocolor plot.
Must be used as a kwarg
Shading:
The optional keyword arg shading ('flat' or 'faceted') will
determine whether a black grid is drawn around each pcolor square.
Default 'faceteted' e.g., pcolor(C, shading='flat') pcolor(X, Y,
C, shading='faceted')
Return value is a list of patch objects.
Grid orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for x
and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and matplotlib. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows
and numcols of Z
- plot(self, *args, **kwargs)
- PLOT(*args, **kwargs)
Plot lines and/or markers to the Axes. *args is a variable length
argument, allowing for multiple x,y pairs with an optional format
string. For example, each of the following is legal
plot(x,y) # plot x and y using the default line style and color
plot(x,y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of x, y, fmt groups can be specified, as in
a.plot(x1, y1, 'g^', x2, y2, 'g-')
Return value is a list of lines that were added.
The following line styles are supported:
- : solid line
-- : dashed line
-. : dash-dot line
: : dotted line
. : points
, : pixels
o : circle symbols
^ : triangle up symbols
v : triangle down symbols
< : triangle left symbols
> : triangle right symbols
s : square symbols
+ : plus symbols
x : cross symbols
D : diamond symbols
d : thin diamond symbols
1 : tripod down symbols
2 : tripod up symbols
3 : tripod left symbols
4 : tripod right symbols
h : hexagon symbols
H : rotated hexagon symbols
p : pentagon symbols
| : vertical line symbols
_ : horizontal line symbols
steps : use gnuplot style 'steps' # kwarg only
The following color strings are supported
b : blue
g : green
r : red
c : cyan
m : magenta
y : yellow
k : black
w : white
Line styles and colors are combined in a single format string, as in
'bo' for blue circles.
The **kwargs can be used to set line properties (any property that has
a set_* method). You can use this to set a line label (for auto
legends), linewidth, anitialising, marker face color, etc. Here is an
example:
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs apply
to all those lines, eg
plot(x1, y1, x2, y2, antialising=False)
Neither line will be antialiased.
- plot_date(self, d, y, fmt='bo', tz=None, **kwargs)
- PLOT_DATE(d, y, converter, fmt='bo', tz=None, **kwargs)
d is a sequence of dates represented as float days since
0001-01-01 UTC and y are the y values at those dates. fmt is
a plot format string. kwargs are passed on to plot. See plot
for more information.
See matplotlib.dates for helper functions date2num, num2date
and drange for help on creating the required floating point dates
tz is the timezone - defaults to rc value
- psd(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
The power spectral density by Welches average periodogram method. The
vector x is divided into NFFT length segments. Each segment is
detrended by function detrend and windowed by function window.
noperlap gives the length of the overlap between segments. The
absolute(fft(segment))**2 of each segment are averaged to compute Pxx,
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
NFFT is the length of the fft segment; must be a power of 2
Fs is the sampling frequency.
detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
For plotting, the power is plotted as 10*log10(pxx)) for decibels,
though pxx itself is returned
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, **kwargs)
- SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0)
Supported function signatures:
SCATTER(x, y) - make a scatter plot of x vs y
SCATTER(x, y, s) - make a scatter plot of x vs y with size in area
given by s
SCATTER(x, y, s, c) - make a scatter plot of x vs y with size in area
given by s and colors given by c
SCATTER(x, y, s, c, **kwargs) - control colormapping and scaling
with keyword args; see below
Make a scatter plot of x versus y. s is a size in points^2 a scalar
or an array of the same length as x or y. c is a color and can be a
single color format string or an length(x) array of intensities which
will be mapped by the matplotlib.colors.colormap instance cmap
The marker can be one of
's' : square
'o' : circle
'^' : triangle up
'>' : triangle right
'v' : triangle down
'<' : triangle left
'd' : diamond
'p' : pentagram
'h' : hexagon
'8' : octagon
s is a size argument in points squared.
Other keyword args; the color mapping and normalization arguments will
on be used if c is an array of floats
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to rc image.cmap
* norm = normalize() : matplotlib.colors.normalize is used to
scale luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. Note if you pass a norm
instance, your settings for vmin and vmax will be ignored
* alpha =1.0 : the alpha value for the patches
- scatter_classic(self, x, y, s=None, c='b')
- SCATTER_CLASSIC(x, y, s=None, c='b')
Make a scatter plot of x versus y. s is a size (in data coords) and
can be either a scalar or an array of the same length as x or y. c is
a color and can be a single color format string or an length(x) array
of intensities which will be mapped by the colormap jet.
If size is None a default size will be used
- semilogx(self, *args, **kwargs)
- SEMILOGX(*args, **kwargs)
Make a semilog plot with log scaling on the x axis. The args to
semilog x are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_xscale. Notable, for log scaling:
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to
range(2,basex)
- semilogy(self, *args, **kwargs)
- SEMILOGY(*args, **kwargs):
Make a semilog plot with log scaling on the y axis. The args to
semilogy are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_yscale. Notable, for log scaling:
* basey: base of the logarithm
* subsy: the location of the minor ticks; None defaults to
range(2,basey)
- set_axis_bgcolor(self, color)
- set the axes bacground color
- set_axis_off(self)
- turn off the axis
- set_axis_on(self)
- turn on the axis
- set_frame_on(self, b)
- Set whether the axes rectangle patch is drawn with boolean b
- set_image_extent(self, xmin, xmax, ymin, ymax)
- Set the data units of the image. This is useful if you want to
plot other things over the image, eg, lines or scatter
- set_position(self, pos)
- Set the axes position with pos = [left, bottom, width, height]
in relative 0,1 coords
- set_title(self, label, fontdict=None, **kwargs)
- SET_TITLE(label, fontdict=None, **kwargs):
Set the title for the xaxis. See the text docstring for information
of how override and the optional args work
- set_xlim(self, v, emit=True)
- SET_XLIM(v, emit=True)
Set the limits for the xaxis; v = [xmin, xmax]
If emit is false, do not trigger an event
- set_xscale(self, value, basex=10, subsx=None)
- SET_XSCALE(value, basex=10, subsx=None)
Set the xscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
- set_xticklabels(self, labels, fontdict=None, **kwargs)
- SET_XTICKLABELS(labels, fontdict=None, **kwargs)
Set the xtick labels with list of strings labels Return a list of axis
text instances
- set_xticks(self, ticks)
- Set the x ticks with list of ticks
- set_ylim(self, v, emit=True)
- SET_YLIM(v, emit=True)
Set the limits for the xaxis; v = [ymin, ymax]. If emit is false, do
not trigger an event.
- set_yscale(self, value, basey=10, subsy=None)
- SET_YSCALE(value, basey=10, subsy=None)
Set the yscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basey: base of the logarithm
* subsy: the location of the minor ticks; None are the default
range(2,basex)
- set_yticklabels(self, labels, fontdict=None, **kwargs)
- SET_YTICKLABELS(labels, fontdict=None, **kwargs)
Set the ytick labels with list of strings labels. Return a list of
Text instances
- set_yticks(self, ticks)
- Set the y ticks with list of ticks
- specgram(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=128, cmap=None, xextent=None)
- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
Compute a spectrogram of data in x. Data are split into NFFT length
segements and the PSD of each section is computed. The windowing
function window is applied to each segment, and the amount of overlap
of each segment is specified with noverlap.
* cmap is a colormap; if None use default determined by rc
* xextent is the image extent in the xaxes xextent=xmin, xmax -
default 0, max(bins), 0, max(freqs) where bins is the return
value from matplotlib.mlab.specgram
* See help(psd) for information on the other keyword arguments.
Return value is (Pxx, freqs, bins, im), where
bins are the time points the spectrogram is calculated over
freqs is an array of frequencies
Pxx is a len(times) x len(freqs) array of power
im is a matplotlib.image.AxesImage.
- spy(self, Z, marker='s', markersize=10, **kwargs)
- SPY(Z, **kwrags) plots the sparsity pattern of the matrix S
using plot markers.
kwargs give the marker properties - see help(plot) for more
information on marker properties
The line handles are returned
- spy2(self, Z)
- SPY2(Z) plots the sparsity pattern of the matrix S as an image
The image instance is returned
- stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
- STEM(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
A stem plot plots vertical lines (using linefmt) at each x location
from the baseline to y, and places a marker there using markerfmt. A
horizontal line at 0 is is plotted using basefmt
Return value is (markerline, stemlines, baseline) .
See
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html
for details and examples/stem_plot.py for a demo.
- table(self, cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None)
- TABLE(cellText=None, cellColours=None,
cellLoc='right', colWidths=None,
rowLabels=None, rowColours=None, rowLoc='left',
colLabels=None, colColours=None, colLoc='center',
loc='bottom', bbox=None):
Add a table to the current axes. Returns a table instance. For
finer grained control over tables, use the Table class and add it
to the axes with add_table.
Thanks to John Gill for providing the class and table.
- text(self, x, y, s, fontdict=None, **kwargs)
- TEXT(x, y, s, fontdict=None, **kwargs)
Add text in string s to axis at location x,y (data coords)
fontdict is a dictionary to override the default text properties.
If fontdict is None, the defaults are determined by your rc
parameters.
Individual keyword arguemnts can be used to override any given
parameter
text(x, y, s, fontsize=12)
The default transform specifies that text is in data coords,
alternatively, you can specify text in axis coords (0,0 lower left and
1,1 upper right). The example below places text in the center of the
axes
text(0.5, 0.5,'matplotlib',
horizontalalignment='center',
verticalalignment='center',
transform = ax.transAxes,
)
- update_datalim(self, xys)
- Update the data lim bbox with seq of xy tups
- vlines(self, x, ymin, ymax, color='k')
- VLINES(x, ymin, ymax, color='k')
Plot vertical lines at each x from ymin to ymax. ymin or ymax can be
scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the heights of the lines are
determined by ymin and ymax
Returns a list of lines that were added
- zoomx(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
- zoomy(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
Methods inherited from matplotlib.artist.Artist:
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_clip_on(self)
- Return whether artist uses clipping
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
|
class Subplot(SubplotBase, Axes) |
|
Emulate matlab's(TM) subplot command, creating axes with
Subplot(numRows, numCols, plotNum)
where plotNum=1 is the first plot number and increasing plotNums
fill rows first. max(plotNum)==numRows*numCols
You can leave out the commas if numRows<=numCols<=plotNum<10, as
in
Subplot(211) # 2 rows, 1 column, first (upper) plot |
|
- Method resolution order:
- Subplot
- SubplotBase
- Axes
- matplotlib.artist.Artist
Methods defined here:
- __init__(self, fig, *args, **kwargs)
Methods inherited from SubplotBase:
- is_first_col(self)
- is_first_row(self)
- is_last_col(self)
- is_last_row(self)
Methods inherited from Axes:
- add_artist(self, a)
- Add any artist to the axes
- add_collection(self, collection)
- add a Collection instance to Axes
- add_line(self, l)
- Add a line to the list of plot lines
- add_patch(self, p)
- Add a line to the list of plot lines
- add_table(self, tab)
- Add a table instance to the list of axes tables
- autoscale_view(self)
- autoscale the view limits using the data limits
- axhline(self, y=0, xmin=0, xmax=1, **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)
- axhspan(self, ymin, ymax, xmin=0, xmax=1, **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)
- axvline(self, x=0, ymin=0, ymax=1, **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)
- axvspan(self, xmin, xmax, ymin=0, ymax=1, **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)
- bar(self, left, height, width=0.80000000000000004, bottom=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BAR(left, height, width=0.8, bottom=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
Make a bar plot with rectangles at
left, left+width, 0, height
left and height are Numeric arrays.
Return value is a list of Rectangle patch instances
BAR(left, height, width, bottom,
color, yerr, xerr, capsize, yoff)
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
color specifies the color of the bar
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, width and bottom can be either
scalars or len(x) sequences
This enables you to use bar as the basis for stacked bar
charts, or candlestick plots
- barh(self, x, y, height=0.80000000000000004, left=0, color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
- BARH(x, y, height=0.8, left=0,
color='b', yerr=None, xerr=None, ecolor='k', capsize=3)
BARH(x, y)
The y values give the heights of the center of the bars. The
x values give the length of the bars.
Return value is a list of Rectangle patch instances
Optional arguments
height - the height (thickness) of the bar
left - the x coordinate of the left side of the bar
color specifies the color of the bar
xerr and yerr, if not None, will be used to generate errorbars
on the bar chart
ecolor specifies the color of any errorbar
capsize determines the length in points of the error bar caps
The optional arguments color, height and left can be either
scalars or len(x) sequences
- cla(self)
- Clear the current axes
- clear(self)
- clear the axes
- cohere(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- COHERE(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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.
Returns the tuple Cxy, freqs
Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- connect(self, s, func)
- contour(self, z, x=None, y=None, levels=None, colors=None, linewidths=None, alpha=1.0, fmt='%1.3f')
- CONTOUR(z, x = None, y = None, levels = None, colors = None)
plots contour lines of an image z
z is a 2D array of image values
x and y are 2D arrays with coordinates of z values in the
two directions. x and y do not need to be evenly spaced but must
be of the same shape as z
levels can be a list of level values or the number of levels to be
plotted. If levels == None, a default number of 7 evenly spaced
levels is plotted.
colors is one of these:
- 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 default color for lines.color in
.matplotlibrc is used.
linewidths is one of:
- 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
reg is a 2D region number array with the same dimensions as x and
y. The values of reg should be positive region numbers, and zero fro
zones wich do not exist.
triangle - triangulation array - must be the same shape as reg
alpha : the default transparency of contour lines
fmt is a format string for adding a label to each collection.
Currently this is useful for auto-legending and may be useful down
the road for legend labeling
More information on reg and triangle arrays is in _contour.c
Return value is levels, collections where levels is a list of contour
levels used and collections is a list of
matplotlib.collections.LineCollection instances
- csd(self, x, y, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
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*log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- disconnect(self, cid)
- disconnect from the Axes event.
- draw(self, renderer)
- Draw everything (plot lines, axes, labels)
- errorbar(self, x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False, **kwargs)
- ERRORBAR(x, y, yerr=None, xerr=None,
fmt='b-', ecolor=None, capsize=3, barsabove=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.
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
kwargs are passed on to the plot command for the markers
Return value is a length 2 tuple. The first element is a list of
y symbol lines. The second element is a list of error bar lines.
- fill(self, *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 a is the Axis 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.
The kwargs that are can be used to set line properties (any
property that has a set_* method). You can use this to set edge
color, face color, etc.
- format_coord(self, x, y)
- return a format string formatting the x, y coord
- format_xdata(self, x)
- Return x string formatted. This function will use the attribute
self.fmt_xdata if it is callable, else will fall back on the xaxis
major formatter
- format_ydata(self, y)
- Return y string formatted. This function will use the attribute
self.fmt_ydata if it is callable, else will fall back on the yaxis
major formatter
- get_axis_bgcolor(self)
- Return the axis background color
- get_child_artists(self)
- get_frame(self)
- Return the axes Rectangle frame
- get_images(self)
- return a list of Axes images contained by the Axes
- get_legend(self)
- Return the Legend instance, or None if no legend is defined
- get_lines(self)
- Return a list of lines contained by the Axes
- get_position(self)
- Return the axes rectangle left, bottom, width, height
- get_xaxis(self)
- Return the XAxis instance
- get_xgridlines(self)
- Get the x grid lines as a list of Line2D instances
- get_xlim(self)
- Get the x axis range [xmin, xmax]
- get_xscale(self)
- return the xaxis scale string: log or linear
- get_xticklabels(self)
- Get the xtick labels as a list of Text instances
- get_xticklines(self)
- Get the xtick lines as a list of Line2D instances
- get_xticks(self)
- Return the x ticks as a list of locations
- get_yaxis(self)
- Return the YAxis instance
- get_ygridlines(self)
- Get the y grid lines as a list of Line2D instances
- get_ylim(self)
- Get the y axis range [ymin, ymax]
- get_yscale(self)
- return the yaxis scale string: log or linear
- get_yticklabels(self)
- Get the ytick labels as a list of Text instances
- get_yticklines(self)
- Get the ytick lines as a list of Line2D instances
- get_yticks(self)
- Return the y ticks as a list of locations
- grid(self, b=None)
- Set the axes grids on or off; b is a boolean
if b is None, toggle the grid state
- has_data(self)
- return true if any artists have been added to axes
- hist(self, x, bins=10, normed=0, bottom=0)
- HIST(x, bins=10, normed=0, bottom=0)
Compute the histogram of x. bins is either an integer number of
bins or a sequence giving the bins. x are the data to be binned.
The return values is (n, bins, patches)
If normed is true, the first element of the return tuple will be the
counts normalized to form a probability distribtion, ie,
n/(len(x)*dbin)
- hlines(self, y, xmin, xmax, fmt='k-')
- HLINES(y, xmin, xmax, fmt='k-')
plot horizontal lines at each y from xmin to xmax. xmin or xmax can
be scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the widths of the lines are
determined by xmin and xmax
Returns a list of line instances that were added
- hold(self, b=None)
- HOLD(b=None)
Set the hold state. If hold is None (default), toggle the
hold state. Else set the hold state to boolean value b.
Eg
hold() # toggle hold
hold(True) # hold is on
hold(False) # hold is off
- imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
- IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
IMSHOW(X) - plot image X to current axes, resampling to scale to axes
size (X may be numarray/Numeric array or PIL image)
IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
colormapping etc. See below for details
Display the image in X to current axes. X may be a float array or a
PIL image. If X is a float array, X can have the following shapes
MxN : luminance (grayscale)
MxNx3 : RGB
MxNx4 : RGBA
A matplotlib.image.AxesImage instance is returned
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to rc
image.cmap value (Ignored when X has RGB(A) information)
* aspect is one of: free or preserve. if None, default to rc
image.aspect value
* interpolation is one of: bicubic bilinear blackman100 blackman256
blackman64 nearest sinc144 sinc256 sinc64 spline16 or spline36.
If None, default to rc image.interpolation
* norm is a matplotlib.colors.normalize instance; default is
normalization(). This scales luminance -> 0-1 (Ignored when X is
PIL image).
* 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. If None, default to rc image.origin
* extent is a data xmin, xmax, ymin, ymax for making image plots
registered with data plots. Default is the image dimensions
in pixels
- in_axes(self, xwin, ywin)
- return True is the point xwin, ywin (display coords) are in the Axes
- ishold(self)
- return the HOLD status of the axes
- legend(self, *args, **kwargs)
- LEGEND(*args, **kwargs)
Place a legend on the current axes at location loc. Labels are a
sequence of strings and loc can be a string or an integer specifying
the legend location
USAGE:
Make a legend with existing lines
>>> legend()
legend by itself will try and build a legend using the label
property of the lines/patches/collections. You can set the label of
a line by doing plot(x, y, label='my data') or line.set_label('my
data')
# automatically generate the legend from labels
legend( ('label1', 'label2', 'label3') )
# Make a legend for a list of lines and labels
legend( (line1, line2, line3), ('label1', 'label2', 'label3') )
# Make a legend at a given location, using a location argument
# legend( LABELS, LOC ) or
# legend( LINES, LABELS, LOC )
legend( ('label1', 'label2', 'label3'), loc='upper left')
legend( (line1, line2, line3), ('label1', 'label2', 'label3'), loc=2)
The location codes are
'best' : 0, (currently not supported, defaults to upper right)
'upper right' : 1, (default)
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10,
If none of these are suitable, loc can be a 2-tuple giving x,y
in axes coords, ie,
loc = 0, 1 is left top
loc = 0.5, 0.5 is center, center
and so on. The following kwargs are supported
numpoints = 4 # the number of points in the legend line
prop = FontProperties('smaller') # the font properties
pad = 0.2 # the fractional whitespace inside the legend border
# The kwarg dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
handlelen = 0.05 # the length of the legend lines
handletextsep = 0.02 # the space between the legend line and legend text
axespad = 0.02 # the border between the axes and legend edge
- loglog(self, *args, **kwargs)
- LOGLOG(*args, **kwargs)
Make a loglog plot with log scaling on the a and y axis. The args
to semilog x are the same as the args to plot. See help plot for
more info.
Optional keyword args supported are any of the kwargs
supported by plot or set_xscale or set_yscale. Notable, for
log scaling:
* basex: base of the x logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
* basey: base of the y logarithm
* subsy: the location of the minor yticks; None defaults to range(2,basey)
- panx(self, numsteps)
- Pan the x axis numsteps (plus pan right, minus pan left)
- pany(self, numsteps)
- Pan the x axis numsteps (plus pan up, minus pan down)
- pcolor(self, *args, **kwargs)
- PCOLOR(*args, **kwargs)
Function signatures
PCOLOR(C) - make a pseudocolor plot of matrix C
PCOLOR(X, Y, C) - a pseudo color plot of C on the matrices X and Y
PCOLOR(C, **kwargs) - Use keywork args to control colormapping and
scaling; see below
Optional keywork args are shown with their defaults below (you must
use kwargs for these):
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to cm.jet
* norm = normalize() : matplotlib.colors.normalize is used to scale
luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. If you pass a norm
instance, vmin and vmax will be None
* shading = 'flat' : or 'faceted'. If 'faceted', a black grid is
drawn around each rectangle; if 'flat', edge colors are same as
face colors
* alpha=1.0 : the alpha blending value
Return value is a matplotlib.collections.PatchCollection
object
Grid Orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for
x and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and pylab. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows and
numcols of Z
- pcolor_classic(self, *args, **kwargs)
- PCOLOR_CLASSIC(self, *args, **kwargs)
Function signatures
pcolor(C) - make a pseudocolor plot of matrix C
pcolor(X, Y, C) - a pseudo color plot of C on the matrices X and Y
pcolor(C, cmap=cm.jet) - make a pseudocolor plot of matrix C using
rectangle patches using a colormap jet. Colormaps are avalible
in matplotlib.cm. You must pass this as a kwarg.
pcolor(C, norm=normalize()) - the normalization function used
` to scale your color data to 0-1. must be passed as a kwarg.
pcolor(C, alpha=0.5) - set the alpha of the pseudocolor plot.
Must be used as a kwarg
Shading:
The optional keyword arg shading ('flat' or 'faceted') will
determine whether a black grid is drawn around each pcolor square.
Default 'faceteted' e.g., pcolor(C, shading='flat') pcolor(X, Y,
C, shading='faceted')
Return value is a list of patch objects.
Grid orientation
The behavior of meshgrid in matlab(TM) is a bit counterintuitive for x
and y arrays. For example,
x = arange(7)
y = arange(5)
X, Y = meshgrid(x,y)
Z = rand( len(x), len(y))
pcolor(X, Y, Z)
will fail in matlab and matplotlib. You will probably be
happy with
pcolor(X, Y, transpose(Z))
Likewise, for nonsquare Z,
pcolor(transpose(Z))
will make the x and y axes in the plot agree with the numrows
and numcols of Z
- plot(self, *args, **kwargs)
- PLOT(*args, **kwargs)
Plot lines and/or markers to the Axes. *args is a variable length
argument, allowing for multiple x,y pairs with an optional format
string. For example, each of the following is legal
plot(x,y) # plot x and y using the default line style and color
plot(x,y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of x, y, fmt groups can be specified, as in
a.plot(x1, y1, 'g^', x2, y2, 'g-')
Return value is a list of lines that were added.
The following line styles are supported:
- : solid line
-- : dashed line
-. : dash-dot line
: : dotted line
. : points
, : pixels
o : circle symbols
^ : triangle up symbols
v : triangle down symbols
< : triangle left symbols
> : triangle right symbols
s : square symbols
+ : plus symbols
x : cross symbols
D : diamond symbols
d : thin diamond symbols
1 : tripod down symbols
2 : tripod up symbols
3 : tripod left symbols
4 : tripod right symbols
h : hexagon symbols
H : rotated hexagon symbols
p : pentagon symbols
| : vertical line symbols
_ : horizontal line symbols
steps : use gnuplot style 'steps' # kwarg only
The following color strings are supported
b : blue
g : green
r : red
c : cyan
m : magenta
y : yellow
k : black
w : white
Line styles and colors are combined in a single format string, as in
'bo' for blue circles.
The **kwargs can be used to set line properties (any property that has
a set_* method). You can use this to set a line label (for auto
legends), linewidth, anitialising, marker face color, etc. Here is an
example:
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs apply
to all those lines, eg
plot(x1, y1, x2, y2, antialising=False)
Neither line will be antialiased.
- plot_date(self, d, y, fmt='bo', tz=None, **kwargs)
- PLOT_DATE(d, y, converter, fmt='bo', tz=None, **kwargs)
d is a sequence of dates represented as float days since
0001-01-01 UTC and y are the y values at those dates. fmt is
a plot format string. kwargs are passed on to plot. See plot
for more information.
See matplotlib.dates for helper functions date2num, num2date
and drange for help on creating the required floating point dates
tz is the timezone - defaults to rc value
- psd(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=0)
- PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0)
The power spectral density by Welches average periodogram method. The
vector x is divided into NFFT length segments. Each segment is
detrended by function detrend and windowed by function window.
noperlap gives the length of the overlap between segments. The
absolute(fft(segment))**2 of each segment are averaged to compute Pxx,
with a scaling to correct for power loss due to windowing. Fs is the
sampling frequency.
NFFT is the length of the fft segment; must be a power of 2
Fs is the sampling frequency.
detrend - the function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in matlab,
where the detrend parameter is a vector, in matplotlib is it a
function. The mlab module defines detrend_none, detrend_mean,
detrend_linear, but you can use a custom function as well.
window - the function used to window the segments. window is a
function, unlike in matlab(TM) where it is a vector. mlab defines
window_none, window_hanning, but you can use a custom function
as well.
noverlap gives the length of the overlap between segments.
Returns the tuple Pxx, freqs
For plotting, the power is plotted as 10*log10(pxx)) for decibels,
though pxx itself is returned
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)
- scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, **kwargs)
- SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0)
Supported function signatures:
SCATTER(x, y) - make a scatter plot of x vs y
SCATTER(x, y, s) - make a scatter plot of x vs y with size in area
given by s
SCATTER(x, y, s, c) - make a scatter plot of x vs y with size in area
given by s and colors given by c
SCATTER(x, y, s, c, **kwargs) - control colormapping and scaling
with keyword args; see below
Make a scatter plot of x versus y. s is a size in points^2 a scalar
or an array of the same length as x or y. c is a color and can be a
single color format string or an length(x) array of intensities which
will be mapped by the matplotlib.colors.colormap instance cmap
The marker can be one of
's' : square
'o' : circle
'^' : triangle up
'>' : triangle right
'v' : triangle down
'<' : triangle left
'd' : diamond
'p' : pentagram
'h' : hexagon
'8' : octagon
s is a size argument in points squared.
Other keyword args; the color mapping and normalization arguments will
on be used if c is an array of floats
* cmap = cm.jet : a cm Colormap instance from matplotlib.cm.
defaults to rc image.cmap
* norm = normalize() : matplotlib.colors.normalize is used to
scale luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
with norm to normalize luminance data. If either are None, the
min and max of the color array C is used. Note if you pass a norm
instance, your settings for vmin and vmax will be ignored
* alpha =1.0 : the alpha value for the patches
- scatter_classic(self, x, y, s=None, c='b')
- SCATTER_CLASSIC(x, y, s=None, c='b')
Make a scatter plot of x versus y. s is a size (in data coords) and
can be either a scalar or an array of the same length as x or y. c is
a color and can be a single color format string or an length(x) array
of intensities which will be mapped by the colormap jet.
If size is None a default size will be used
- semilogx(self, *args, **kwargs)
- SEMILOGX(*args, **kwargs)
Make a semilog plot with log scaling on the x axis. The args to
semilog x are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_xscale. Notable, for log scaling:
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to
range(2,basex)
- semilogy(self, *args, **kwargs)
- SEMILOGY(*args, **kwargs):
Make a semilog plot with log scaling on the y axis. The args to
semilogy are the same as the args to plot. See help plot for more
info.
Optional keyword args supported are any of the kwargs supported by
plot or set_yscale. Notable, for log scaling:
* basey: base of the logarithm
* subsy: the location of the minor ticks; None defaults to
range(2,basey)
- set_axis_bgcolor(self, color)
- set the axes bacground color
- set_axis_off(self)
- turn off the axis
- set_axis_on(self)
- turn on the axis
- set_frame_on(self, b)
- Set whether the axes rectangle patch is drawn with boolean b
- set_image_extent(self, xmin, xmax, ymin, ymax)
- Set the data units of the image. This is useful if you want to
plot other things over the image, eg, lines or scatter
- set_position(self, pos)
- Set the axes position with pos = [left, bottom, width, height]
in relative 0,1 coords
- set_title(self, label, fontdict=None, **kwargs)
- SET_TITLE(label, fontdict=None, **kwargs):
Set the title for the xaxis. See the text docstring for information
of how override and the optional args work
- set_xlabel(self, xlabel, fontdict=None, **kwargs)
- SET_XLABEL(xlabel, fontdict=None, **kwargs)
Set the label for the xaxis. See the text docstring for information
of how override and the optional args work.
- set_xlim(self, v, emit=True)
- SET_XLIM(v, emit=True)
Set the limits for the xaxis; v = [xmin, xmax]
If emit is false, do not trigger an event
- set_xscale(self, value, basex=10, subsx=None)
- SET_XSCALE(value, basex=10, subsx=None)
Set the xscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basex: base of the logarithm
* subsx: the location of the minor ticks; None defaults to range(2,basex)
- set_xticklabels(self, labels, fontdict=None, **kwargs)
- SET_XTICKLABELS(labels, fontdict=None, **kwargs)
Set the xtick labels with list of strings labels Return a list of axis
text instances
- set_xticks(self, ticks)
- Set the x ticks with list of ticks
- set_ylabel(self, ylabel, fontdict=None, **kwargs)
- SET_YLABEL(ylabel, fontdict=None, **kwargs)
Set the label for the yaxis
Defaults override is
override = {
'verticalalignment' : 'center',
'horizontalalignment' : 'right',
'rotation'='vertical' : }
See the text doctstring for information of how override and
the optional args work
- set_ylim(self, v, emit=True)
- SET_YLIM(v, emit=True)
Set the limits for the xaxis; v = [ymin, ymax]. If emit is false, do
not trigger an event.
- set_yscale(self, value, basey=10, subsy=None)
- SET_YSCALE(value, basey=10, subsy=None)
Set the yscaling: 'log' or 'linear'
If value is 'log', the additional kwargs have the following meaning
* basey: base of the logarithm
* subsy: the location of the minor ticks; None are the default
range(2,basex)
- set_yticklabels(self, labels, fontdict=None, **kwargs)
- SET_YTICKLABELS(labels, fontdict=None, **kwargs)
Set the ytick labels with list of strings labels. Return a list of
Text instances
- set_yticks(self, ticks)
- Set the y ticks with list of ticks
- specgram(self, x, NFFT=256, Fs=2, detrend=<function detrend_none>, window=<function window_hanning>, noverlap=128, cmap=None, xextent=None)
- SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap=None, xextent=None)
Compute a spectrogram of data in x. Data are split into NFFT length
segements and the PSD of each section is computed. The windowing
function window is applied to each segment, and the amount of overlap
of each segment is specified with noverlap.
* cmap is a colormap; if None use default determined by rc
* xextent is the image extent in the xaxes xextent=xmin, xmax -
default 0, max(bins), 0, max(freqs) where bins is the return
value from matplotlib.mlab.specgram
* See help(psd) for information on the other keyword arguments.
Return value is (Pxx, freqs, bins, im), where
bins are the time points the spectrogram is calculated over
freqs is an array of frequencies
Pxx is a len(times) x len(freqs) array of power
im is a matplotlib.image.AxesImage.
- spy(self, Z, marker='s', markersize=10, **kwargs)
- SPY(Z, **kwrags) plots the sparsity pattern of the matrix S
using plot markers.
kwargs give the marker properties - see help(plot) for more
information on marker properties
The line handles are returned
- spy2(self, Z)
- SPY2(Z) plots the sparsity pattern of the matrix S as an image
The image instance is returned
- stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
- STEM(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
A stem plot plots vertical lines (using linefmt) at each x location
from the baseline to y, and places a marker there using markerfmt. A
horizontal line at 0 is is plotted using basefmt
Return value is (markerline, stemlines, baseline) .
See
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html
for details and examples/stem_plot.py for a demo.
- table(self, cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None)
- TABLE(cellText=None, cellColours=None,
cellLoc='right', colWidths=None,
rowLabels=None, rowColours=None, rowLoc='left',
colLabels=None, colColours=None, colLoc='center',
loc='bottom', bbox=None):
Add a table to the current axes. Returns a table instance. For
finer grained control over tables, use the Table class and add it
to the axes with add_table.
Thanks to John Gill for providing the class and table.
- text(self, x, y, s, fontdict=None, **kwargs)
- TEXT(x, y, s, fontdict=None, **kwargs)
Add text in string s to axis at location x,y (data coords)
fontdict is a dictionary to override the default text properties.
If fontdict is None, the defaults are determined by your rc
parameters.
Individual keyword arguemnts can be used to override any given
parameter
text(x, y, s, fontsize=12)
The default transform specifies that text is in data coords,
alternatively, you can specify text in axis coords (0,0 lower left and
1,1 upper right). The example below places text in the center of the
axes
text(0.5, 0.5,'matplotlib',
horizontalalignment='center',
verticalalignment='center',
transform = ax.transAxes,
)
- update_datalim(self, xys)
- Update the data lim bbox with seq of xy tups
- vlines(self, x, ymin, ymax, color='k')
- VLINES(x, ymin, ymax, color='k')
Plot vertical lines at each x from ymin to ymax. ymin or ymax can be
scalars or len(x) numpy arrays. If they are scalars, then the
respective values are constant, else the heights of the lines are
determined by ymin and ymax
Returns a list of lines that were added
- zoomx(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
- zoomy(self, numsteps)
- Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)
Methods inherited from matplotlib.artist.Artist:
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_clip_on(self)
- Return whether artist uses clipping
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
|
class SubplotBase |
|
Emulate matlab's(TM) subplot command, creating axes with
Subplot(numRows, numCols, plotNum)
where plotNum=1 is the first plot number and increasing plotNums
fill rows first. max(plotNum)==numRows*numCols
You can leave out the commas if numRows<=numCols<=plotNum<10, as
in
Subplot(211) # 2 rows, 1 column, first (upper) plot |
|
Methods defined here:
- __init__(self, *args)
- is_first_col(self)
- is_first_row(self)
- is_last_col(self)
- is_last_row(self)
| |