Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Regenerate background when RectangleSelector active-flag is set back on.#17480

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:masterfromanntzer:rsa
Oct 2, 2020

Conversation

anntzer
Copy link
Contributor

Otherwise, if the selector is made inactive and then back to active, the
"old" selector gets captured in the background image and spurious
appears.

No tests because good luck with that, but can be tried with
examples/widgets/rectangle_selector.py.

Closes#17476.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@QuLogic
Copy link
Member

Is this only needed forRectangleSelector?

@QuLogic
Copy link
Member

And if so, maybe this should overrideset_active instead?

@anntzer
Copy link
ContributorAuthor

set_active calls update_background, so that's fine?
Haven't checked the other widgets.

@QuLogic
Copy link
Member

EllipseSelector derives fromRectangleSelector so it'll be fine; the others don't appear to be problematic.

@QuLogic
Copy link
Member

Wait, I forgot to setuseblit=True; this does affectPolygonSelector, which doesn't derive fromRectangleSelector.

Also affectsSpanSelector if you toggle it in the middle of selecting something.

@anntzer
Copy link
ContributorAuthor

Do you have an example where this can easily be checked? Is that just a matter of moving theupdate_background implementation fully to the base class?

@QuLogic
Copy link
Member

I essentially patched the examples to do whatRectangleSelector did:

diff --git a/examples/widgets/polygon_selector_demo.py b/examples/widgets/polygon_selector_demo.pyindex c1340679f3..68de0e0e9a 100644--- a/examples/widgets/polygon_selector_demo.py+++ b/examples/widgets/polygon_selector_demo.py@@ -50,9 +50,17 @@ class SelectFromCollection:         elif len(self.fc) == 1:             self.fc = np.tile(self.fc, (self.Npts, 1))-        self.poly = PolygonSelector(ax, self.onselect)+        self.poly = PolygonSelector(ax, self.onselect, useblit=False)         self.ind = []+        self.cid = self.canvas.mpl_connect('key_press_event',+                                           self.toggle_selector)++    def toggle_selector(self, event):+        if event.key == 't':+            self.poly.set_active(not self.poly.active)+            print('Selector toggled')+     def onselect(self, verts):         path = Path(verts)         self.ind = np.nonzero(path.contains_points(self.xys))[0]diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.pyindex 2e720f4c98..3955c8f540 100644--- a/examples/widgets/span_selector.py+++ b/examples/widgets/span_selector.py@@ -46,9 +46,17 @@ def onselect(xmin, xmax): #+def toggle_selector(event):+    if event.key == 't':+        span.set_active(not span.active)+        print('Span toggled')++ span = SpanSelector(ax1, onselect, 'horizontal', useblit=True,                     rectprops=dict(alpha=0.5, facecolor='red')) # Set useblit=True on most backends for enhanced performance.+fig.canvas.mpl_connect('key_press_event', toggle_selector)+  plt.show()

@anntzer
Copy link
ContributorAuthor

OK, moving everything to the base class seems to work.

Otherwise, if the selector is made inactive and then back to active, the"old" selector gets captured in the background image and spuriousappears.No tests because good luck with that, but can be tried withexamples/widgets/rectangle_selector.py.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

RectangleSelector fails to clear itself after being toggled inactive and then back to active.
3 participants
@anntzer@QuLogic@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp