Package asap :: Module asaplotbase :: Class asaplotbase
[show private | hide private]
[frames | no frames]

Class asaplotbase

Known Subclasses:
asaplot, asaplotgui, asaplotgui

ASAP plotting base class based on matplotlib.
Method Summary
  __init__(self, rows, cols, title, size, buffering)
Create a new instance of the ASAPlot plotting class.
  clear(self)
Delete all lines from the plot.
  delete(self, numbers)
Delete the 0-relative line number, default is to delete the last.
  get_line(self)
Get the current default line attributes.
  hist(self, x, y, fmt, add)
Plot a histogram.
  hold(self, hold)
Buffer graphics until subsequently released.
  legend(self, loc)
Add a legend to the plot.
  palette(self, color, colormap, linestyle, linestyles)
  plot(self, x, y, fmt, add)
Plot the next line in the current frame using the current line attributes.
  position(self)
Use the mouse to get a position from a graph.
  region(self)
Use the mouse to get a rectangular region from a plot.
  register(self, type, func)
Register, reregister, or deregister events of type 'button_press', 'button_release', or 'motion_notify'.
  release(self)
Release buffered graphics.
  save(self, fname, orientation, dpi, papertype)
Save the plot to a file.
  set_axes(self, what, *args, **kwargs)
Set attributes for the axes by calling the relevant Axes.set_*() method.
  set_figure(self, what, *args, **kwargs)
Set attributes for the figure by calling the relevant Figure.set_*() method.
  set_limits(self, xlim, ylim)
Set x-, and y-limits for each subplot.
  set_line(self, number, **kwargs)
Set attributes for the specified line, or else the next line(s) to be plotted.
  set_panels(self, rows, cols, n, nplots, ganged)
Set the panel layout.
  set_title(self, title)
Set the title of the plot window.
  show(self, hardrefresh)
Show graphics dependent on the current buffering state.
  subplot(self, i, inc)
Set the subplot to the 0-relative panel number as defined by one or more invokations of set_panels().
  text(self, *args, **kwargs)
Add text to the figure.
  tidy(self)
  vline_with_label(self, x, y, label, location, rotate, **kwargs)
Plot a vertical line with label.

Method Details

__init__(self, rows=1, cols=0, title='', size=(8, 6), buffering=False)
(Constructor)

Create a new instance of the ASAPlot plotting class.

If rows < 1 then a separate call to set_panels() is required to define the panel layout; refer to the doctext for set_panels().

clear(self)

Delete all lines from the plot. Line numbering will restart from 0.

delete(self, numbers=None)

Delete the 0-relative line number, default is to delete the last. The remaining lines are NOT renumbered.

get_line(self)

Get the current default line attributes.

hist(self, x=None, y=None, fmt=None, add=None)

Plot a histogram. N.B. the x values refer to the start of the histogram bin.

fmt is the line style as in plot().

hold(self, hold=True)

Buffer graphics until subsequently released.

legend(self, loc=None)

Add a legend to the plot.

Any other value for loc else disables the legend:
     1: upper right
     2: upper left
     3: lower left
     4: lower right
     5: right
     6: center left
     7: center right
     8: lower center
     9: upper center
    10: center

plot(self, x=None, y=None, fmt=None, add=None)

Plot the next line in the current frame using the current line attributes. The ASAPlot graphics window will be mapped and raised.

The argument list works a bit like the matlab plot() function.

position(self)

Use the mouse to get a position from a graph.

region(self)

Use the mouse to get a rectangular region from a plot.

The return value is [x0, y0, x1, y1] in world coordinates.

register(self, type=None, func=None)

Register, reregister, or deregister events of type 'button_press',
'button_release', or 'motion_notify'.

The specified callback function should have the following signature:

    def func(event)

where event is an MplEvent instance containing the following data:

    name                # Event name.
    canvas              # FigureCanvas instance generating the event.
    x      = None       # x position - pixels from left of canvas.
    y      = None       # y position - pixels from bottom of canvas.
    button = None       # Button pressed: None, 1, 2, 3.
    key    = None       # Key pressed: None, chr(range(255)), shift,
                          win, or control
    inaxes = None       # Axes instance if cursor within axes.
    xdata  = None       # x world coordinate.
    ydata  = None       # y world coordinate.

For example:

    def mouse_move(event):
        print event.xdata, event.ydata

    a = asaplot()
    a.register('motion_notify', mouse_move)

If func is None, the event is deregistered.

Note that in TkAgg keyboard button presses don't generate an event.

release(self)

Release buffered graphics.

save(self, fname=None, orientation=None, dpi=None, papertype=None)

Save the plot to a file.

fname is the name of the output file. The image format is determined from the file suffix; 'png', 'ps', and 'eps' are recognized. If no file name is specified 'yyyymmdd_hhmmss.png' is created in the current directory.

set_axes(self, what=None, *args, **kwargs)

Set attributes for the axes by calling the relevant Axes.set_*() method. Colour translation is done as described in the doctext for palette().

set_figure(self, what=None, *args, **kwargs)

Set attributes for the figure by calling the relevant Figure.set_*() method. Colour translation is done as described in the doctext for palette().

set_limits(self, xlim=None, ylim=None)

Set x-, and y-limits for each subplot.

xlim = [xmin, xmax] as in axes.set_xlim(). ylim = [ymin, ymax] as in axes.set_ylim().

set_line(self, number=None, **kwargs)

Set attributes for the specified line, or else the next line(s)
to be plotted.

number is the 0-relative number of a line that has already been
plotted.  If no such line exists, attributes are recorded and used
for the next line(s) to be plotted.

Keyword arguments specify Line2D attributes, e.g. color='r'.  Do

    import matplotlib
    help(matplotlib.lines)

The set_* methods of class Line2D define the attribute names and
values.  For non-US usage, "colour" is recognized as synonymous with
"color".

Set the value to None to delete an attribute.

Colour translation is done as described in the doctext for palette().

set_panels(self, rows=1, cols=0, n=-1, nplots=-1, ganged=True)

Set the panel layout.

rows and cols, if cols != 0, specify the number of rows and columns in a regular layout. (Indexing of these panels in matplotlib is row- major, i.e. column varies fastest.)

cols == 0 is interpreted as a retangular layout that accomodates 'rows' panels, e.g. rows == 6, cols == 0 is equivalent to rows == 2, cols == 3.

0 <= n < rows*cols is interpreted as the 0-relative panel number in the configuration specified by rows and cols to be added to the current figure as its next 0-relative panel number (i). This allows non-regular panel layouts to be constructed via multiple calls. Any other value of n clears the plot and produces a rectangular array of empty panels. The number of these may be limited by nplots.

set_title(self, title=None)

Set the title of the plot window. Use the previous title if title is omitted.

show(self, hardrefresh=True)

Show graphics dependent on the current buffering state.

subplot(self, i=None, inc=None)

Set the subplot to the 0-relative panel number as defined by one or more invokations of set_panels().

text(self, *args, **kwargs)

Add text to the figure.

vline_with_label(self, x, y, label, location='bottom', rotate=0.0, **kwargs)

Plot a vertical line with label. It takes "world" values fo x and y.

Generated by Epydoc 2.1 on Wed May 2 14:24:32 2007 http://epydoc.sf.net