Skip to content
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

zoom/pan stack bug in 2.1.0 #9358

Closed
DeadParrot opened this issue Oct 11, 2017 · 15 comments
Closed

zoom/pan stack bug in 2.1.0 #9358

DeadParrot opened this issue Oct 11, 2017 · 15 comments
Milestone

Comments

@DeadParrot
Copy link

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, ...
@tacaswell tacaswell added this to the 2.1.1 (next bug fix release) milestone Oct 11, 2017
@tacaswell
Copy link
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....

@anntzer
Copy link
Contributor

anntzer commented Oct 11, 2017

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.

@DeadParrot
Copy link
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.

@tacaswell
Copy link
Member

Do you have a toolbar installed in your widget?

@DeadParrot
Copy link
Author

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

@anntzer
Copy link
Contributor

anntzer commented Oct 11, 2017

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.

@2sn
Copy link

2sn commented Oct 11, 2017

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.

@2sn
Copy link

2sn commented Oct 24, 2017

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

@2sn
Copy link

2sn commented Oct 24, 2017

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

@tacaswell
Copy link
Member

Fixed by #9359

@DeadParrot
Copy link
Author

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

@2sn
Copy link

2sn commented Mar 7, 2018 via email

@2sn
Copy link

2sn commented Mar 11, 2018

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

@anntzer
Copy link
Contributor

anntzer commented Mar 11, 2018

Can't reproduce it either...

@DeadParrot
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants