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

GUI Neutral widgets
 
All of these widgets require you to predefine an Axes instance and
pass that as the first arg.  matplotlib doesn't try to be too smart in
layout -- you have to figure out how wide and tall you want your Axes
to be to accommodate your widget.

 
Modules
       
thread

 
Classes
       
Cursor
LockDraw
MultiCursor
RectangleSelector
SpanSelector
HorizontalSpanSelector
Widget
Button
CheckButtons
Lasso
RadioButtons
Slider
SubplotTool

 
class Button(Widget)
    A GUI neutral button
 
The following attributes are accesible
 
  ax    - the Axes the button renders into
  label - a text.Text instance
  color - the color of the button when not hovering
  hovercolor - the color of the button when hovering
 
Call "on_clicked" to connect to the button
 
  Methods defined here:
__init__(self, ax, label, image=None, color='0.85', hovercolor='0.95')
ax is the Axes instance the button will be placed into
 
label is a string which is the button text
 
image if not None, is an image to place in the button -- can
  be any legal arg to imshow (array, matplotlib Image
  instance, or PIL image)
 
color is the color of the button when not activated
 
hovercolor is the color of the button when the mouse is over
  it
disconnect(self, cid)
remove the observer with connection id cid
on_clicked(self, func)
When the button is clicked, call this func with event
 
A connection id is returned which can be used to disconnect

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class CheckButtons(Widget)
    A GUI neutral radio button
 
The following attributes are exposed
 
 ax - the Axes instance the buttons are in
 labels - a list of text.Text instances
 lines - a list of (line1, line2) tuples for the x's in the check boxes.
         These lines exist for each box, but have set_visible(False) when
         box is not checked
 rectangles - a list of patch.Rectangle instances
 
Connect to the CheckButtons with the on_clicked method
 
  Methods defined here:
__init__(self, ax, labels, actives)
Add check buttons to axes.Axes instance ax
 
labels is a len(buttons) list of labels as strings
 
actives is a len(buttons) list of booleans indicating whether
 the button is active
disconnect(self, cid)
remove the observer with connection id cid
on_clicked(self, func)
When the button is clicked, call this func with button label
 
A connection id is returned which can be used to disconnect

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class Cursor
    A horizontal and vertical line span the axes that and move with
the pointer.  You can turn off the hline or vline spectively with
the attributes
 
  horizOn =True|False: controls visibility of the horizontal line
  vertOn =True|False: controls visibility of the horizontal line
 
And the visibility of the cursor itself with visible attribute
 
  Methods defined here:
__init__(self, ax, useblit=False, **lineprops)
Add a cursor to ax.  If useblit=True, use the backend
dependent blitting features for faster updates (GTKAgg only
now).  lineprops is a dictionary of line properties.  See
examples/widgets/cursor.py.
clear(self, event)
clear the cursor
onmove(self, event)
on mouse motion draw the cursor if visible

 
class HorizontalSpanSelector(SpanSelector)
    # For backwards compatibility only!
 
  Methods defined here:
__init__(self, ax, onselect, **kwargs)

Methods inherited from SpanSelector:
ignore(self, event)
return True if event should be ignored
onmove(self, event)
on motion notify event
press(self, event)
on button press event
release(self, event)
on button release event
update(self)
draw using newfangled blit or oldfangled draw depending on useblit
update_background(self, event)
force an update of the background

 
class Lasso(Widget)
     Methods defined here:
__init__(self, ax, xy, callback=None, useblit=True)
onmove(self, event)
onrelease(self, event)

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class LockDraw
    some widgets, like the cursor, draw onto the canvas, and this is not
desirable under all circumstaces, like when the toolbar is in
zoom-to-rect mode and drawing a rectangle.  The module level "lock"
allows someone to grab the lock and prevent other widgets from
drawing.  Use matplotlib.widgets.lock(someobj) to pr
 
  Methods defined here:
__call__(self, o)
reserve the lock for o
__init__(self)
available(self, o)
drawing is available to o
isowner(self, o)
o owns the lock
locked(self)
the lock is held
release(self, o)
release the lock

 
class MultiCursor
    Provide a vertical line cursor shared between multiple axes
 
from matplotlib.widgets import MultiCursor
from pylab import figure, show, nx
 
t = nx.arange(0.0, 2.0, 0.01)
s1 = nx.sin(2*nx.pi*t)
s2 = nx.sin(4*nx.pi*t)
fig = figure()
ax1 = fig.add_subplot(211)
ax1.plot(t, s1)
 
 
ax2 = fig.add_subplot(212, sharex=ax1)
ax2.plot(t, s2)
 
multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)
show()
 
  Methods defined here:
__init__(self, canvas, axes, useblit=True, **lineprops)
clear(self, event)
clear the cursor
onmove(self, event)

 
class RadioButtons(Widget)
    A GUI neutral radio button
 
The following attributes are exposed
 
 ax - the Axes instance the buttons are in
 activecolor - the color of the button when clicked
 labels - a list of text.Text instances
 circles - a list of patch.Circle instances
 
Connect to the RadioButtons with the on_clicked method
 
  Methods defined here:
__init__(self, ax, labels, active=0, activecolor='blue')
Add radio buttons to axes.Axes instance ax
 
labels is a len(buttons) list of labels as strings
 
active is the index into labels for the button that is active
 
activecolor is the color of the button when clicked
disconnect(self, cid)
remove the observer with connection id cid
on_clicked(self, func)
When the button is clicked, call this func with button label
 
A connection id is returned which can be used to disconnect

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class RectangleSelector
    Select a min/max range of the x axes for a matplotlib Axes
 
Example usage:
 
  ax = subplot(111)
  ax.plot(x,y)
 
  def onselect(eclick, erelease):
      'eclick and erelease are matplotlib events at press and release'
      print 'startposition : (%f,%f)'%(eclick.xdata, eclick.ydata)
      print 'endposition   : (%f,%f)'%(erelease.xdata, erelease.ydata)
      print 'used button   : ', eclick.button
 
  span = Selector(ax, onselect,drawtype='box')
  show()
 
  Methods defined here:
__init__(self, ax, onselect, drawtype='box', minspanx=None, minspany=None, useblit=False, lineprops=None, rectprops=None)
Create a selector in ax.  When a selection is made, clear
the span and call onselect with
 
  onselect(pos_1, pos_2)
 
and clear the drawn box/line. There pos_i are arrays of length 2
containing the x- and y-coordinate.
 
If minspanx is not None then events smaller than minspanx
in x direction are ignored(it's the same for y).
 
The rect is drawn with rectprops; default
  rectprops = dict(facecolor='red', edgecolor = 'black',
                   alpha=0.5, fill=False)
 
The line is drawn with lineprops; default
  lineprops = dict(color='black', linestyle='-',
                   linewidth = 2, alpha=0.5)
 
Use type if you want the mouse to draw a line, a box or nothing
between click and actual position ny setting
drawtype = 'line', drawtype='box' or drawtype = 'none'.
ignore(self, event)
return True if event should be ignored
onmove(self, event)
on motion notify event if box/line is wanted
press(self, event)
on button press event
release(self, event)
on button release event
update(self)
draw using newfangled blit or oldfangled draw depending on useblit
update_background(self, event)
force an update of the background

 
class Slider(Widget)
    A slider representing a floating point range
 
The following attributes are defined
  ax     : the slider axes.Axes instance
  val    : the current slider value
  vline  : a Line2D instance representing the initial value
  poly   : A patch.Polygon instance which is the slider
  valfmt : the format string for formatting the slider text
  label  : a text.Text instance, the slider label
  closedmin : whether the slider is closed on the minimum
  closedmax : whether the slider is closed on the maximum
  slidermin : another slider - if not None, this slider must be > slidermin
  slidermax : another slider - if not None, this slider must be < slidermax
  dragging : allow for mouse dragging on slider
 
Call on_changed to connect to the slider event
 
  Methods defined here:
__init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt='%1.2f', closedmin=True, closedmax=True, slidermin=None, slidermax=None, dragging=True)
Create a slider from valmin to valmax in axes ax;
 
valinit -  the slider initial position
 
label - the slider label
 
valfmt - used to format the slider value
 
closedmin and closedmax - indicate whether the slider interval is closed
 
slidermin and slidermax - be used to contrain the value of
  this slider to the values of other sliders.
disconnect(self, cid)
remove the observer with connection id cid
on_changed(self, func)
When the slider valud is changed, call this func with the new
slider position
 
A connection id is returned which can be used to disconnect
reset(self)
reset the slider to the initial value if needed
set_val(self, val)

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class SpanSelector
    Select a min/max range of the x or y axes for a matplotlib Axes
 
Example usage:
 
  ax = subplot(111)
  ax.plot(x,y)
 
  def onselect(vmin, vmax):
      print vmin, vmax
  span = SpanSelector(ax, onselect, 'horizontal')
 
  onmove_callback is an optional callback that will be called on mouse move
  with the span range
 
  Methods defined here:
__init__(self, ax, onselect, direction, minspan=None, useblit=False, rectprops=None, onmove_callback=None)
Create a span selector in ax.  When a selection is made, clear
the span and call onselect with
 
  onselect(vmin, vmax)
 
and clear the span.
 
direction must be 'horizontal' or 'vertical'
 
If minspan is not None, ignore events smaller than minspan
 
The span rect is drawn with rectprops; default
  rectprops = dict(facecolor='red', alpha=0.5)
 
set the visible attribute to False if you want to turn off
the functionality of the span selector
ignore(self, event)
return True if event should be ignored
onmove(self, event)
on motion notify event
press(self, event)
on button press event
release(self, event)
on button release event
update(self)
draw using newfangled blit or oldfangled draw depending on useblit
update_background(self, event)
force an update of the background

 
class SubplotTool(Widget)
    A tool to adjust to subplot params of fig
 
  Methods defined here:
__init__(self, targetfig, toolfig)
targetfig is the figure to adjust
 
toolfig is the figure to embed the the subplot tool into.  If
None, a default pylab figure will be created.  If you are
using this from the GUI
funcbottom(self, val)
funchspace(self, val)
funcleft(self, val)
funcright(self, val)
functop(self, val)
funcwspace(self, val)

Data and other attributes inherited from Widget:
drawon = True
eventson = True

 
class Widget
    OK, I couldn't resist; abstract base class for mpl GUI neutral
widgets
 
  Data and other attributes defined here:
drawon = True
eventson = True

@footer@