@header@
 
 
matplotlib.figure
index
/usr/lib/python2.4/site-packages/matplotlib/figure.py

Figure class -- add docstring here!

 
Modules
       
matplotlib._image
matplotlib.colorbar
sys
warnings

 
Classes
       
matplotlib.artist.Artist
Figure
SubplotParams

 
class Figure(matplotlib.artist.Artist)
     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
add_axes(self, *args, **kwargs)
Add an a axes with axes rect [left, bottom, width, height] where all
quantities are in fractions of figure width and height.  kwargs are
legal Axes kwargs plus "polar" which sets whether to create a polar axes
 
    rect = l,b,w,h
    add_axes(rect)
    add_axes(rect, frameon=False, axisbg='g')
    add_axes(rect, polar=True)
    add_axes(ax)   # add an Axes instance
 
 
If the figure already has an axes with key *args, *kwargs then it will
simply make that axes current and return it.  If you do not want this
behavior, eg you want to force the creation of a new axes, you must
use a unique set of args and kwargs.  The artist "label" attribute has
been exposed for this purpose.  Eg, if you want two axes that are
otherwise identical to be added to the figure, make sure you give them
unique labels:
 
    add_axes(rect, label='axes1')
    add_axes(rect, label='axes2')
 
The Axes instance will be returned
add_axobserver(self, func)
whenever the axes state change, func(self) will be called
add_subplot(self, *args, **kwargs)
Add a subplot.  Examples
 
    add_subplot(111)
    add_subplot(212, axisbg='r')  # add subplot with red background
    add_subplot(111, polar=True)  # add a polar subplot
    add_subplot(sub)              # add Subplot instance sub
 
kwargs are legal Axes kwargs plus"polar" which sets whether to create a
polar axes.  The Axes instance will be returned.
 
If the figure already has a subplot with key *args, *kwargs then it will
simply make that subplot current and return it
clear(self)
Clear the figure
clf(self)
Clear the figure
colorbar(self, mappable, cax=None, **kw)
        Create a colorbar for a ScalarMappable instance.
 
        Documentation for the pylab thin wrapper: 
Add a colorbar to a plot.
 
Function signatures:
 
    colorbar(**kwargs)
 
    colorbar(mappable, **kwargs)
 
    colorbar(mappable, cax, **kwargs)
 
The optional arguments mappable and cax may be included in the kwargs;
they are image, ContourSet, etc. to which the colorbar applies, and
the axes object in which the colorbar will be drawn.  Defaults are
the current image and a new axes object created next to that image
after resizing the image.
 
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=no_norm()),
        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.
colorbar_classic(self, mappable, cax=None, orientation='vertical', tickfmt='%1.1f', cspacing='proportional', clabels=None, drawedges=False, edgewidth=0.5, edgecolor='k')
Create a colorbar for mappable image
 
mappable is the cm.ScalarMappable instance that you want the
colorbar to apply to, e.g. an Image as returned by imshow or a
PatchCollection as returned by scatter or pcolor.
 
tickfmt is a format string to format the colorbar ticks
 
cax is a colorbar axes instance in which the colorbar will be
placed.  If None, as default axesd will be created resizing the
current aqxes to make room for it.  If not None, the supplied axes
will be used and the other axes positions will be unchanged.
 
orientation is the colorbar orientation: one of 'vertical' | 'horizontal'
 
cspacing controls how colors are distributed on the colorbar.
if cspacing == 'linear', each color occupies an equal area
on the colorbar, regardless of the contour spacing.
if cspacing == 'proportional' (Default), the area each color
occupies on the the colorbar is proportional to the contour interval.
Only relevant for a Contour image.
 
clabels can be a sequence containing the
contour levels to be labelled on the colorbar, or None (Default).
If clabels is None, labels for all contour intervals are
displayed. Only relevant for a Contour image.
 
if drawedges == True, lines are drawn at the edges between
each color on the colorbar. Default False.
 
edgecolor is the line color delimiting the edges of the colors
on the colorbar (if drawedges == True). Default black ('k')
 
edgewidth is the width of the lines delimiting the edges of
the colors on the colorbar (if drawedges == True). Default 0.5
 
return value is the colorbar axes instance
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
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
get_axes(self)
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
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, loc, **kwargs)
Place a legend in the figure.  Labels are a sequence of
strings, handles is a sequence of line or patch instances, and
loc can be a string 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, 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,
 
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
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 'pdf', 'png', 'ps', 'svg'. It is used to specify the
         output when fname is a file or file-like object - cairo
         backend only.
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*
 
ACCEPTS: a w,h tuple with w,h in inches
subplots_adjust(self, *args, **kwargs)
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

Methods inherited from matplotlib.artist.Artist:
add_callback(self, func)
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_figure(self)
return the figure instance
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
pchanged(self)
fire event when property changed
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_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)
update_from(self, other)
copy properties from other to self

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

 
Functions
       
Bbox(...)
Bbox(ll, ur)
Point(...)
Point(x, y)
Value(...)
Value(x)
figaspect(arg)
Create a figure with specified aspect ratio.  If arg is a number,
use that aspect ratio.  If arg is an array, figaspect will
determine the width and height for a figure that would fit array
preserving aspect ratio.  The figure width, height in inches are
returned.  Be sure to create an axes with equal with and height,
eg
 
Example usage:
 
  # make a figure twice as tall as it is wide
  w, h = figaspect(2.)
  fig = Figure(figsize=(w,h))
  ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
  ax.imshow(A, **kwargs)
 
 
  # make a figure with the proper aspect for an array
  A = rand(5,3)
  w, h = figaspect(A)
  fig = Figure(figsize=(w,h))
  ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
  ax.imshow(A, **kwargs)
 
Thanks to Fernando Perez for this function

 
Data
        maximum = <ufunc 'maximum'>
minimum = <ufunc 'minimum'>
rcParams = {'axes.axisbelow': False, 'axes.edgecolor': 'k', 'axes.facecolor': 'w', 'axes.grid': False, 'axes.hold': True, 'axes.labelcolor': 'k', 'axes.labelsize': 'medium', 'axes.linewidth': 1.0, 'axes.titlesize': 'large', 'backend': 'GTKAgg', ...}
@footer@