Skip to content

zoom/pan stack bug in 2.1.0 #9358

Closed
Closed

Description

@DeadParrot

For plots after the first one created on a canvas the zoom/pan stacks can have _pos == -1 and, due to a change in 2.1.0 (fb83117), this position offset error causes unzoom and unpan back operations to think they have reached the top of the stack one step before they have.

The code change that causes this was the removal of these lines from press_pan and press_zoom:

if self._views.empty():
    self.push_current()

which reset the Stack _pos to 0. Restoring this code corrects the issue but may not be the desired fix given the intended refactoring.

Matplotlib version

  • Operating system: Windows
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt4Agg
  • Python version: 2.7.14
  • Other libraries: latest NumPy, PySide, ...

Activity

  1. added this to the milestone on Oct 11, 2017
  2. tacaswell commented on Oct 11, 2017

    @tacaswell
    Member

    attn @anntzer

    This was changed in fb83117

    The call back that was added for draw_event should have made it so that those conditionals should never be true iirc....

  3. anntzer commented on Oct 11, 2017

    @anntzer
    Contributor

    I'm looking at it, but it's not obvious why the previous code (before that patch) would even work for dynamically added axes. @DeadParrot Can you describe the sequence of actions / code that allows reproducing the issue (and used to work in 2.0)? Thanks.

  4. DeadParrot commented on Oct 11, 2017

    @DeadParrot
    Author

    Sure, @anntzer. We have a QWidget that has a matplotlib canvas that we reuse for plots of different data sets the user selects. We could but we don't discard the canvas between plots. The _pos is -1 on entry to the first press_pan or press_zoom call for each plot after the first plot. If I can replicate this in a small example I'll post that here.

  5. tacaswell commented on Oct 11, 2017

    @tacaswell
    Member

    Do you have a toolbar installed in your widget?

  6. DeadParrot commented on Oct 11, 2017

    @DeadParrot
    Author

    Yes. We have a toolbar and we also wired up right-click to call back().

  7. anntzer commented on Oct 11, 2017

    @anntzer
    Contributor

    OK, so I think the correct fix is to keep define_home hooked to draw_event and have it check whether the axes set has changed or not. If it has, push the state.

  8. 2sn commented on Oct 11, 2017

    @2sn

    I have the same issue in standard plots using TkAgg/Python 3.6.3. The original state is lost, the home button only gets me back to the first zoom/pan action. Even for vanilla plots of the kind

    f = plt.figure()
    ax = f.add_subplot()
    

    (nothing else)

    The you move a few times, then press the home button - but don't return to the original zoom/viewport.

    This seems to be particularly reproducible in ipython, less so under plain python3.

  9. 2sn commented on Oct 24, 2017

    @2sn

    I seem to still see that issue on the current master branch but #9359 seems to fix it. Seems rather important to fix/merge.

  10. 2sn commented on Oct 24, 2017

    @2sn

    Is there a way to manually add the "home" zoom/pan level to the stack until this is fixed?

  11. tacaswell commented on Nov 13, 2017

    @tacaswell
    Member

    Fixed by #9359

  12. DeadParrot commented on Mar 7, 2018

    @DeadParrot
    Author

    @tacaswell @anntzer Sadly, this seems to be broken again in 2.2.0. I can open a new issue for this if preferred.

  13. 2sn commented on Mar 7, 2018

    @2sn
  14. 2sn commented on Mar 11, 2018

    @2sn

    @DeadParrot I have to admit, I cannot reproduce/confirm the existence of this issue in 2.2.0. Could you please provide an example?

  15. anntzer commented on Mar 11, 2018

    @anntzer
    Contributor

    Can't reproduce it either...

  16. DeadParrot commented on Mar 12, 2018

    @DeadParrot
    Author

    Sorry for the delay. I tried to build small examples showing the issue but since these worked I looked into our code and it looks like our toolbar class overrode the update method in a way that worked before but didn't in 2.2.0. I was able to resolve our issue by restoring the inherited update behavior and I'm hoping this doesn't again break things for our users on older matplotlib versions.

    Upshot is that there was definitely an internal change in 2.2.0 that tripped us up but I can't conclude that it is a bug so let's leave this closed for now. Thanks!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions