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

Skip to content

Add zoom_factory to matplotlib - where to put? #18159

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

Open
ianhi opened this issue Aug 3, 2020 · 3 comments
Open

Add zoom_factory to matplotlib - where to put? #18159

ianhi opened this issue Aug 3, 2020 · 3 comments

Comments

@ianhi
Copy link
Contributor

ianhi commented Aug 3, 2020

@tacaswell wrote a zoom_factory function that enables zooming with the mouse scroll wheel in this gist: https://gist.github.com/tacaswell/3144287 this is very useful and would be great if it was offered as a utility function by matplotlib. In mpl-extensions/mpl-interactions#21 (comment) tacaswell wrote:

I am 👍 on a PR to core Matplotlib to add that factory (not sure where) as it is useful in all backends (not just ipympl).

So this issue is to discuss whether/where to incorporate the zoom_factory function. Two initial suggestions:

  1. in the toolbar
  2. in pyplot
    • Architecturally I don't think this makes as much sense but as a user I don't think I would expect to look at the toolbar for utility methods

Additionally I forked that gist (https://gist.github.com/ianhi/b638e09fa7a00764ea539940a0519af9) and added two things:

  1. push initial position to toolbar navstack so the home button works as expected
  2. automatic centering when zoomed out past initial bounds
    • This could be made optional

if this were to be incorporated in matplotlib it would be nice to have those features as well.

Here is a gif of this with with some extra code to allow middle click to pan(https://gist.github.com/ianhi/5f514c31f13cc28fbd167849867122b7):

@tacaswell tacaswell added this to the v3.4.0 milestone Aug 3, 2020
@tacaswell
Copy link
Member

It should not go in pyplot as we want this available to people who avoid the global state tracking of pyplot.

This should probably go in https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backend_tools.py and target the MEP22 style toolbars. I suspect that we would want to have this enabled by default on the zoom tool?

@ianhi
Copy link
Contributor Author

ianhi commented Aug 3, 2020

I suspect that we would want to have this enabled by default on the zoom tool?

Do you mean on zoom to rect? I think that adding this to the panning mode feels the most natural:
image

though it will be good to keep this available outside of a toolbar button to allow greater control. For instance I use this with middle click to pan and left click to use the lasso tool.

@ianhi
Copy link
Contributor Author

ianhi commented Jun 17, 2021

This would be fixed by #20317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants