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

Lasso selector #730

merged 13 commits into from
Mar 17, 2012

Conversation

tonysyu
Copy link
Contributor

@tonysyu tonysyu commented Mar 1, 2012

Add LassoSelector widget that behaves more like RectangleSelector and SpanSelector than the current Lasso widget.

Note: I put the demo in the "widgets" directory even though the Lasso demo is in "event_handling".

Also, note that this PR builds off of PR #724: Only the last commit in this PR adds the new widget.

* This change is in preparation for generalizing the base Widget.
* It's not clear to me why `new_axes` is necessary, but I left it in (for now).
* Renamed `Lasso.axes` to `Lasso.ax` for consistency.
* Remove `Lasso.figure`, which was unused.
* Attribute name "active" can be confused with parameter to `RadioButtons`, but `RadioButtons` doesn't save that parameter as an attribute, so there's no name clash. BUT this is still really confusing to users. Consider renaming `AxesWidget.active`.
*
* * This could have been implemented as a decorator, but some callbacks wouldn't be compatible. For example, `SpanSelector.release` should not be ignored if widget was deactivated during mouse press.
*
* * `SpanSelector` and `RectangleSelector` already had `ignore` methods, but they do not call it in `update_background`. I don't change the current behavior, although it seems desirable.
Also, remove unused import.
Note: I put the demo in the "widgets" directory even though the `Lasso` demo is in "event_handling".
@@ -64,9 +63,41 @@ class Widget(object):
eventson = True


class AxesWidget(Widget):
"""
Widget that is connected to a single :class:`Axes`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this render correctly? It is certainly safer to do :class:~matplotlib.axes.Axes. (the tilde shortens the link to Axes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about this. Thanks for the tip.

import numpy as np

from matplotlib.widgets import LassoSelector
from matplotlib.nxutils import points_inside_poly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't work since nxutils was removed in master... see #732 for example of how to get around that one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm on the latest master, and it works fine on my system. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually,... I didn't clean out my build, so I had a leftover nxutils.so. I just converted to use Path.contains_point. Thanks for the tip!

@efiring
Copy link
Member

efiring commented Mar 12, 2012

Please add docstrings for Lasso and LassoSelector.

@tonysyu
Copy link
Contributor Author

tonysyu commented Mar 12, 2012

@efiring doctstrings, done.

efiring added a commit that referenced this pull request Mar 17, 2012
@efiring efiring merged commit adf6680 into matplotlib:master Mar 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants