-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Lasso selector #730
Conversation
* 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`. |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Class links were incorrect.
import numpy as np | ||
|
||
from matplotlib.widgets import LassoSelector | ||
from matplotlib.nxutils import points_inside_poly |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
Please add docstrings for Lasso and LassoSelector. |
`nxutils` is removed from master.
@efiring doctstrings, done. |
Add
LassoSelector
widget that behaves more likeRectangleSelector
andSpanSelector
than the currentLasso
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.