| |
- __builtin__.object
-
- BlockingMouseInput
- matplotlib.artist.Artist(__builtin__.object)
-
- Figure
- SubplotParams
class BlockingMouseInput(__builtin__.object) |
|
Class that creates a callable object to retrieve mouse clicks in a
blocking way. |
|
Methods defined here:
- __call__(self, n=1, timeout=30, verbose=False, show_clicks=True)
- Blocking call to retrieve n coordinate pairs through mouse
clicks.
- __init__(self, fig)
- on_click(self, event)
- Event handler that will be passed to the current figure to
retrieve clicks.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Figure(matplotlib.artist.Artist) |
|
The Figure instance supports callbacks through a callbacks
attribute which is a cbook.CallbackRegistry instance. The events
you can connect to are 'dpi_changed', and the callback will be
called with func(fig) where fig is the Figure instance |
|
- Method resolution order:
- Figure
- matplotlib.artist.Artist
- __builtin__.object
Methods defined here:
- __init__(self, figsize=None, dpi=None, facecolor=None, edgecolor=None, linewidth=1.0, frameon=True, subplotpars=None)
- figsize is a w,h tuple in inches
dpi is dots per inch
subplotpars is a SubplotParams instance, defaults to rc
- __str__(self)
- add_axes(self, *args, **kwargs)
- add_axobserver(self, func)
- whenever the axes state change, func(self) will be called
- add_subplot(self, *args, **kwargs)
- autofmt_xdate(self, bottom=0.20000000000000001, rotation=30, ha='right')
- Date ticklabels often overlap, so it is useful to rotate them
and right align them. Also, a common use case is a number of
subplots with shared xaxes where the x-axis is date data. The
ticklabels are often long, and it helps to rotate them on the
bottom subplot and turn them off on other subplots, as well as
turn off xlabels.
bottom : the bottom of the subplots for subplots_adjust
rotation: the rotation of the xtick labels
ha : the horizontal alignment of the xticklabels
- clear(self)
- Clear the figure
- clf(self)
- Clear the figure
- colorbar(self, mappable, cax=None, ax=None, **kw)
- Create a colorbar for a ScalarMappable instance.
Documentation for the pylab thin wrapper:
Add a colorbar to a plot.
Function signatures for the pyplot interface; all but the first are
also method signatures for the Figure.colorbar method:
colorbar(**kwargs)
colorbar(mappable, **kwargs)
colorbar(mappable, cax=cax, **kwargs)
colorbar(mappable, ax=ax, **kwargs)
arguments:
mappable: the image, ContourSet, etc. to which the colorbar applies;
this argument is mandatory for the Figure.colorbar
method but optional for the pyplot.colorbar function,
which sets the default to the current image.
keyword arguments:
cax: None | axes object into which the colorbar will be drawn
ax: None | parent axes object from which space for a new
colorbar axes will be stolen
**kwargs are in two groups:
axes properties:
fraction = 0.15; fraction of original axes to use for colorbar
pad = 0.05 if vertical, 0.15 if horizontal; fraction
of original axes between colorbar and
new image axes
shrink = 1.0; fraction by which to shrink the colorbar
aspect = 20; ratio of long to short dimensions
colorbar properties:
extend='neither', 'both', 'min', 'max'
If not 'neither', make pointed end(s) for out-of-range
values. These are set for a given colormap using the
colormap set_under and set_over methods.
spacing='uniform', 'proportional'
Uniform spacing gives each discrete color the same space;
proportional makes the space proportional to the data interval.
ticks=None, list of ticks, Locator object
If None, ticks are determined automatically from the input.
format=None, format string, Formatter object
If none, the ScalarFormatter is used.
If a format string is given, e.g. '%.3f', that is used.
An alternative Formatter object may be given instead.
drawedges=False, True
If true, draw lines at color boundaries.
The following will probably be useful only in the context of
indexed colors (that is, when the mappable has norm=NoNorm()),
or other unusual circumstances.
boundaries=None or a sequence
values=None or a sequence which must be of length 1 less than the
sequence of boundaries.
For each region delimited by adjacent entries in
boundaries, the color mapped to the corresponding
value in values will be used.
If mappable is a ContourSet, its extend kwarg is included automatically.
Note that the shrink kwarg provides a simple way to keep
a vertical colorbar, for example, from being taller than
the axes of the mappable to which the colorbar is attached;
but it is a manual method requiring some trial and error.
If the colorbar is too tall (or a horizontal colorbar is
too wide) use a smaller value of shrink.
For more precise control, you can manually specify the
positions of the axes objects in which the mappable and
the colorbar are drawn. In this case, do not use any of the
axes properties kwargs.
- contains(self, mouseevent)
- Test whether the mouse event occurred on the figure.
Returns True,{}
- delaxes(self, a)
- remove a from the figure and update the current axes
- draw(self, renderer)
- Render the figure using Renderer instance renderer
- draw_artist(self, a)
- draw artist only -- this is available only after the figure is drawn
- enable_auto_layout(self, setting=True)
- figimage(self, X, xo=0, yo=0, alpha=1.0, norm=None, cmap=None, vmin=None, vmax=None, origin=None)
- FIGIMAGE(X) # add non-resampled array to figure
FIGIMAGE(X, xo, yo) # with pixel offsets
FIGIMAGE(X, **kwargs) # control interpolation ,scaling, etc
Add a nonresampled figure to the figure from array X. xo and yo are
offsets in pixels
X must be a float array
If X is MxN, assume luminance (grayscale)
If X is MxNx3, assume RGB
If X is MxNx4, assume RGBA
The following kwargs are allowed:
* cmap is a cm colormap instance, eg cm.jet. If None, default to
the rc image.cmap valuex
* norm is a matplotlib.colors.Normalize instance; default is
normalization(). This scales luminance -> 0-1
* vmin and vmax are used to scale a luminance image to 0-1. If
either is None, the min and max of the luminance values will be
used. Note if you pass a norm instance, the settings for vmin and
vmax will be ignored.
* alpha = 1.0 : the alpha blending value
* origin is either 'upper' or 'lower', which indicates where the [0,0]
index of the array is in the upper left or lower left corner of
the axes. Defaults to the rc image.origin value
This complements the axes image (Axes.imshow) which will be resampled
to fit the current axes. If you want a resampled image to fill the
entire figure, you can define an Axes with size [0,1,0,1].
A image.FigureImage instance is returned.
- gca(self, **kwargs)
- Return the current axes, creating one if necessary
The following kwargs are supported
adjustable: ['box' | 'datalim']
alpha: float
anchor: ['C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W']
animated: [True | False]
aspect: ['auto' | 'equal' | aspect_ratio]
autoscale_on: True|False
axes: an axes instance
axis_bgcolor: any matplotlib color - see help(colors)
axis_off: void
axis_on: void
axisbelow: True|False
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color_cycle: unknown
contains: unknown
cursor_props: a (float, color) tuple
figure: a Figure instance
frame_on: True|False
label: any string
lod: [True | False]
navigate: True|False
navigate_mode: unknown
picker: [None|float|boolean|callable]
position: len(4) sequence of floats, or a Bbox object
title: unknown
transform: a matplotlib.transform transformation instance
visible: [True | False]
xbound: unknown
xlabel: unknown
xlim: len(2) sequence of floats
xscale: unknown
xticklabels: unknown
xticks: sequence of floats
ybound: unknown
ylabel: unknown
ylim: len(2) sequence of floats
yscale: unknown
yticklabels: unknown
yticks: sequence of floats
zorder: any number
- get_axes(self)
- get_children(self)
- get a list of artists contained in the figure
- get_dpi(self)
- Return the dpi as a float
- get_edgecolor(self)
- Get the edge color of the Figure rectangle
- get_facecolor(self)
- Get the face color of the Figure rectangle
- get_figheight(self)
- Return the figheight as a float
- get_figwidth(self)
- Return the figwidth as a float
- get_frameon(self)
- get the boolean indicating frameon
- get_size_inches(self)
- get_window_extent(self, *args, **kwargs)
- get the figure bounding box in display space; kwargs are void
- ginput(self, n=1, timeout=30, verbose=False, show_clicks=True)
- ginput(self, n=1, timeout=30, verbose=False, show_clicks=True)
Blocking call to interact with the figure.
This will wait for n clicks from the user and return a list of the
coordinates of each click. If timeout is negative, does not
timeout. If n is negative, accumulate clicks until a middle
click terminates the input. Right clicking cancels last input.
- hold(self, 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
- legend(self, handles, labels, *args, **kwargs)
- Place a legend in the figure. Labels are a sequence of
strings, handles is a sequence of line or patch instances, and
loc can be a string or an integer specifying the legend
location
USAGE:
legend( (line1, line2, line3),
('label1', 'label2', 'label3'),
'upper right')
The LOC location codes are
'best' : 0, (currently not supported for figure legends)
'upper right' : 1,
'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,
loc can also be an (x,y) tuple in figure coords, which
specifies the lower left of the legend box. figure coords are
(0,0) is the left, bottom of the figure and 1,1 is the right,
top.
The legend instance is returned. The following kwargs are supported:
loc = "upper right" #
numpoints = 4 # the number of points in the legend line
prop = FontProperties(size='smaller') # the font property
pad = 0.2 # the fractional whitespace inside the legend border
markerscale = 0.6 # the relative size of legend markers vs. original
shadow # if True, draw a shadow behind legend
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
- savefig(self, *args, **kwargs)
- SAVEFIG(fname, dpi=None, facecolor='w', edgecolor='w',
orientation='portrait', papertype=None, format=None):
Save the current figure.
fname - the filename to save the current figure to. The
output formats supported depend on the backend being
used. and are deduced by the extension to fname.
Possibilities are eps, jpeg, pdf, png, ps, svg. fname
can also be a file or file-like object - cairo backend
only.
dpi - is the resolution in dots per inch. If
None it will default to the value savefig.dpi in the
matplotlibrc file
facecolor and edgecolor are the colors of the figure rectangle
orientation is either 'landscape' or 'portrait' - not supported on
all backends; currently only on postscript output
papertype is is one of 'letter', 'legal', 'executive', 'ledger', 'a0'
through 'a10', or 'b0' through 'b10' - only supported for postscript
output
format - one of the file extensions supported by the active backend.
- sca(self, a)
- Set the current axes to be a and return a
- set_canvas(self, canvas)
- Set the canvas the contains the figure
ACCEPTS: a FigureCanvas instance
- set_dpi(self, val)
- Set the dots-per-inch of the figure
ACCEPTS: float
- set_edgecolor(self, color)
- Set the edge color of the Figure rectangle
ACCEPTS: any matplotlib color - see help(colors)
- set_facecolor(self, color)
- Set the face color of the Figure rectangle
ACCEPTS: any matplotlib color - see help(colors)
- set_figheight(self, val)
- Set the height of the figure in inches
ACCEPTS: float
- set_figsize_inches(self, *args, **kwargs)
- set_figwidth(self, val)
- Set the width of the figure in inches
ACCEPTS: float
- set_frameon(self, b)
- Set whether the figure frame (background) is displayed or invisible
ACCEPTS: boolean
- set_size_inches(self, *args, **kwargs)
- set_size_inches(w,h, forward=False)
Set the figure size in inches
Usage: set_size_inches(self, w,h) OR
set_size_inches(self, (w,h) )
optional kwarg forward=True will cause the canvas size to be
automatically updated; eg you can resize the figure window
from the shell
WARNING: forward=True is broken on all backends except GTK*
and WX*
ACCEPTS: a w,h tuple with w,h in inches
- subplots_adjust(self, *args, **kwargs)
- subplots_adjust(self, left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None)
fig.subplots_adjust(left=None, bottom=None, right=None, wspace=None, hspace=None):
Update the SubplotParams with kwargs (defaulting to rc where
None) and update the subplot locations
- text(self, x, y, s, *args, **kwargs)
- Add text to figure at location x,y (relative 0-1 coords) See
the help for Axis text for the meaning of the other arguments
kwargs control the Text properties:
alpha: float
animated: [True | False]
axes: an axes instance
backgroundcolor: any matplotlib color
bbox: rectangle prop dict plus key 'pad' which is a pad in points
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: a Path instance and a Transform instance, a Patch
color: any matplotlib color
contains: unknown
family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure: a matplotlib.figure.Figure instance
fontproperties: a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
label: any string
linespacing: float
lod: [True | False]
multialignment: ['left' | 'right' | 'center' ]
name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
picker: [None|float|boolean|callable]
position: (x,y)
rotation: [ angle in degrees 'vertical' | 'horizontal'
size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle: [ 'normal' | 'italic' | 'oblique']
text: string or anything printable with '%s' conversion
transform: a matplotlib.transform transformation instance
variant: [ 'normal' | 'small-caps' ]
verticalalignment or va: [ 'center' | 'top' | 'bottom' | 'baseline' ]
visible: [True | False]
weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x: float
y: float
zorder: any number
Data descriptors defined here:
- dpi
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert x using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert y using yaxis unit type
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or None for default.
- get_figure(self)
- return the figure instance
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- return the Transformation instance used by this artist
- get_transformed_clip_path_and_affine(self)
- Return the clip path with the non-affine part of its transformation applied,
and the remaining affine part of its transformation.
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return True if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- pick(mouseevent)
each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
- pickable(self)
- return True if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect will not
be visible until the figure is redrawn, e.g., with ax.draw_idle().
Call ax.relim() to update the axes limits if desired.
Note: relim() will not see collections even if the collection
was added to axes with autolim=True.
Note: there is no support for removing the artist's legend entry.
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_axes(self, axes)
- set the axes instance the artist resides in, if any
ACCEPTS: an axes instance
- 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_clip_path(self, path, transform=None)
- Set the artist's clip path, which may be:
a) a Patch (or subclass) instance
b) a Path instance, in which cas aoptional transform may
be provided, which will be applied to the path before using it
for clipping.
c) None, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to None.
ACCEPTS: a Path instance and a Transform instance, a Patch
instance, or None
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event:
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return hit=True and props
is a dictionary of properties you want returned with the contains test.
- 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_picker(self, picker)
- set the epsilon for picking used by this artist
picker can be one of the following:
None - picking is disabled for this artist (default)
boolean - if True then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
float - if picker is a number it is interpreted as an
epsilon tolerance in points and the the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, eg the indices of the data within
epsilon of the pick event
function - if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event.
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return hit=True and props is a dictionary of
properties you want added to the PickEvent attributes
ACCEPTS: [None|float|boolean|callable]
- 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)
- update_from(self, other)
- copy properties from other to self
Data descriptors inherited from matplotlib.artist.Artist:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
|
class SubplotParams |
|
A class to hold the parameters for a subplot |
|
Methods defined here:
- __init__(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
- All dimensions are fraction of the figure width or height.
All values default to their rc params
The following attributes are available:
left : the left side of the subplots of the figure
right : the right side of the subplots of the figure
bottom : the bottom of the subplots of the figure
top : the top of the subplots of the figure
wspace : the amount of width reserved for blank space between subplots
hspace : the amount of height reserved for white space between subplots
validate : make sure the params are in a legal state
(left<right, etc)
- update(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
- Update the current values. If any kwarg is None, default to
the current value, if set, otherwise to rc
| |