Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lasso selector #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 17, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add docstrings for Lasso and LassoSelector.
  • Loading branch information
tonysyu committed Mar 12, 2012
commit 78798f153f9f285f7c95c41eab711d113ffeb634
50 changes: 50 additions & 0 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,35 @@ def get_active(self):


class LassoSelector(AxesWidget):
"""Selection curve of an arbitrary shape.

The selected path can be used in conjunction with
:function:`~matplotlib.path.Path.contains_point` to select
data points from an image.

In contrast to :class:`Lasso`, `LassoSelector` is written with an interface
similar to :class:`RectangleSelector` and :class:`SpanSelector` and will
continue to interact with the axes until disconnected.

Parameters:

*ax* : :class:`~matplotlib.axes.Axes`
The parent axes for the widget.
*onselect* : function
Whenever the lasso is released, the `onselect` function is called and
passed the vertices of the selected path.

Example usage::

ax = subplot(111)
ax.plot(x,y)

def onselect(verts):
print verts
lasso = LassoSelector(ax, onselect)

"""

def __init__(self, ax, onselect=None, useblit=True, lineprops=None):
AxesWidget.__init__(self, ax)

Expand Down Expand Up @@ -1482,6 +1511,27 @@ def update_background(self, event):


class Lasso(AxesWidget):
"""Selection curve of an arbitrary shape.

The selected path can be used in conjunction with
:function:`~matplotlib.path.Path.contains_point` to select
data points from an image.

Unlike :class:`LassoSelector`, this must be initialized with a starting
point `xy`, and the `Lasso` events are destroyed upon release.

Parameters:

*ax* : :class:`~matplotlib.axes.Axes`
The parent axes for the widget.
*xy* : array
Coordinates of the start of the lasso.
*callback* : function
Whenever the lasso is released, the `callback` function is called and
passed the vertices of the selected path.

"""

def __init__(self, ax, xy, callback=None, useblit=True):
AxesWidget.__init__(self, ax)

Expand Down