Skip to content

Add zoom_factory to matplotlib - where to put? #18159

Open
@ianhi

Description

@ianhi

@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):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions