Skip to content

Regression in get_navigate_mode() return value #18150

Closed

Description

@timhoffm

Bug report

#17135 simplified pan/zoom toggling.

The values of the _Mode enum are returned via get_navigate_mode() (https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.get_navigate_mode.html).

This is a breaking API change. Before the returned values were 'PAN', 'ZOOM', or None (as is still documented). Now, these values are 'pan/zoom', 'zoom rect' and ''. Ping @anntzer I don't see if these values translate 1:1. Why is _Mode.PAN = 'pan/zoom'?

Activity

  1. added this to the v3.3.1 milestone on Aug 2, 2020
  2. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Aug 2, 2020
  3. anntzer commented on Aug 2, 2020

    @anntzer
    Contributor

    That's just because I confused ax.{get,set}_navigate_mode() ('PAN'/'ZOOM'/None) and toolbar.mode ('pan/zoom'/'zoom rect'/''). I think this just needs something like

    diff --git i/lib/matplotlib/backend_bases.py w/lib/matplotlib/backend_bases.py
    index 2dd41cdf5..f42a7664f 100644
    --- i/lib/matplotlib/backend_bases.py
    +++ w/lib/matplotlib/backend_bases.py
    @@ -2784,6 +2784,10 @@ class _Mode(str, Enum):
         def __str__(self):
             return self.value
     
    +    @property
    +    def _navigate_mode(self):
    +        return {"NONE": None, "PAN": "PAN", "ZOOM": "ZOOM"}[self.name]
    +
     
     class NavigationToolbar2:
         """
    @@ -3047,7 +3051,7 @@ class NavigationToolbar2:
                 self.mode = _Mode.PAN
                 self.canvas.widgetlock(self)
             for a in self.canvas.figure.get_axes():
    -            a.set_navigate_mode(self.mode)
    +            a.set_navigate_mode(self.mode._navigate_mode)
             self.set_message(self.mode)
     
         def press_pan(self, event):
    @@ -3117,7 +3121,7 @@ class NavigationToolbar2:
                 self.mode = _Mode.ZOOM
                 self.canvas.widgetlock(self)
             for a in self.canvas.figure.get_axes():
    -            a.set_navigate_mode(self.mode)
    +            a.set_navigate_mode(self.mode._navigate_mode)
             self.set_message(self.mode)
     
         def press_zoom(self, event):

    ?

  4. QuLogic commented on Aug 4, 2020

    @QuLogic
    Member

    Went with a slightly different implementation. Too bad it isn't 'NONE' instead of None, though.

  5. added a commit that references this issue on Aug 4, 2020
    f4a75f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: toolbar

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions