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

Appearance settings

Let widgets/clabel better handle overlapping axes. #25555

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 1 commit into from
Jun 13, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 26, 2023

In general, using event.inaxes/event.xdata/event.ydata can be error-prone when there are overlapping axes, because only the topmost axes is the "in"-axes.

In the specific case of widgets/clabel, in particular, we can instead check whether an event occurred over the axes and if so compute xdata/ydata accordingly. Doing so allows correct handling of widgets on axes for which there's also a twin axes on top of it.

Changes in the tests (other than the change in test_span_selector, which tests the functionality here) ensure that the synthetic button presses indeed occur on top of the desired axes (previously, do_event would directly set event.inaxes and we'd just believe that "as is").

Closes #10009 (by actually fixing the issue, not by documenting the limitation).
Also closes #25030.

PR Summary

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@anntzer anntzer force-pushed the wia branch 2 times, most recently from 44f27da to 98e8d69 Compare March 26, 2023 22:19
@anntzer anntzer changed the title Let widgets better handle overlapping axes. Let widgets/clabel better handle overlapping axes. Mar 27, 2023
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
In general, using event.inaxes/event.xdata/event.ydata can be
error-prone when there are overlapping axes, because only the topmost
axes is the "in"-axes.

In the specific case of widgets/clabel, in particular, we can instead
check whether an event occurred over the axes and if so compute
xdata/ydata accordingly.  Doing so allows correct handling of widgets on
axes for which there's also a twin axes on top of it.

Changes in the tests (other than the change in test_span_selector, which
tests the functionality here) ensure that the synthetic button presses
indeed occur on top of the desired axes (previously, do_event would
directly set event.inaxes and we'd just believe that "as is").
@anntzer
Copy link
Contributor Author

anntzer commented May 25, 2023

thanks, comments handled.

@jklymak jklymak requested a review from oscargus June 13, 2023 16:09
@oscargus oscargus merged commit 94edf8a into matplotlib:main Jun 13, 2023
@oscargus oscargus added this to the v3.8.0 milestone Jun 13, 2023
@anntzer anntzer deleted the wia branch June 13, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Button widgets don't work in inset axes document event handling with twined axes
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.