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

Skip to content

Simplify and generalize _set_view_from_bbox. #17067

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
Apr 10, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Apr 8, 2020

_set_view_from_bbox is called to figure out the new axes limits when the
mouse is released in interactive zoom.

  • In the common zoom-in case, simplify the code by using set_x/ybound
    which maintains the previously existing axes inversion (if any),
    rather than having a bunch of conditions to sort the arguments
    correctly before passing them to set_x/ylim.

  • In the (more rarely used?) zoom-out case (which is triggered by
    right-clicking, and zooms the axes out so that the previous axes
    limits fit in the drawn box), use the axis transform directly rather
    than just special-casing log-scale; this is necessary to make zoom-out
    work for other scales such as logit.

  • Tiny cleanups to the len(bbox) == 3 case, which is only used by
    toolmanager to implement zoom-by-scroll, but isn't used by the default
    toolbar zoom.

Also add a test for this previously untested path.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

@anntzer anntzer added this to the v3.3.0 milestone Apr 8, 2020
_set_view_from_bbox is called to figure out the new axes limits when the
mouse is released in interactive zoom.

- In the common zoom-in case, simplify the code by using `set_x/ybound`
  which maintains the previously existing axes inversion (if any),
  rather than having a bunch of conditions to sort the arguments
  correctly before passing them to `set_x/ylim`.

- In the (more rarely used?) zoom-out case (which is triggered by
  right-clicking, and zooms the axes out so that the previous axes
  limits fit in the drawn box), use the axis transform directly rather
  than just special-casing log-scale; this is necessary to make zoom-out
  work for other scales such as logit.

- Tiny cleanups to the `len(bbox) == 3` case, which is only used by
  toolmanager to implement zoom-by-scroll, but isn't used by the default
  toolbar zoom.

Also add a test for this previously untested path.
@anntzer anntzer force-pushed the zoomlogit branch 2 times, most recently from 957a9e4 to 2f6d98c Compare April 8, 2020 15:03
@tacaswell
Copy link
Member

I personally use the zoom out fairly often.

@QuLogic
Copy link
Member

QuLogic commented Apr 10, 2020

Ignoring failure, which is the macOS tight bbox thing.

@QuLogic QuLogic merged commit 47a15d9 into matplotlib:master Apr 10, 2020
@anntzer anntzer deleted the zoomlogit branch April 10, 2020 08:48
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