Skip to content

Navigation does not work after figure.clf() #9730

Closed

Description

@awacha

Bug report

Bug summary

Navigation in the zoom stack using the Home, Forward, Backward buttons on the toolbar does not work after the figure is cleared with clf().

Code for reproduction

plt.plot([1,2,3])
plt.clf()
plt.plot([1,2,3])
# now click the Zoom button and try to zoom in/out on the figure. Then press Home, Forward or Back buttons on the navigation toolbar: nothing happens.

Actual outcome

The Home, Forward and Back buttons on the toolbar do not work: the zoom does not change as expected.

Expected outcome

Stepping forward and backward in the zoom stack should work as expected when pressing the navigation buttons.

Matplotlib version

  • Operating system: Linux 64
  • Matplotlib version: v2.0.2, v2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): tried Qt5 and Tk, possibly all others are affected
  • Python version: 3.6
  • Jupyter version (if applicable): -
  • Other libraries: -

I use conda, python3.6 and matplotlib (v2.0.2) from the default channel and matplotlib (v2.1.0) from conda-forge.

Activity

  1. tacaswell commented on Nov 9, 2017

    @tacaswell
    Member

    Can you try with master or 2.1.x? I think this is fixed by #9359

  2. added this to the v2.1.1 milestone on Nov 9, 2017
  3. awacha commented on Nov 9, 2017

    @awacha
    Author

    Dear Thomas,

    I have tried with the current HEAD (bdb8568), but the problem is still there. I have done a bit more extensive testing and found the following:

    1. start with a simple plot (e.g. plt.plot([1,2,3]))
    2. zoom in several times
    3. "back" and "forward" work as expected, but "home" does not rewind the history stack as I would expect, just inserts another stack element at the current point with the original zoom state.
    4. If you now plt.clf() and do another plot, the situation is different:
      -- "back" and "forward" work as expected.
      -- if you press "back" while at the first point of the stack, you can no more go "forward"
      -- "home" does not work: nothing happens. The same zoom state remains, and "back" and "forward" no longer work.

    Please let me know if and how I can help diagnosing.

  4. tacaswell commented on Nov 9, 2017

    @tacaswell
    Member

    I think 'home' in this context means "go to original view" not "fully rewind my history". Either does make sense, but the implementation is what it is so behavior 3 is probably not going to change (imaging the bug report of someone who has been using the current behavior).

    Behavior 4 sounds like a bug (or two) though.

  5. modified the milestones: v2.1.1, on Nov 9, 2017
  6. tacaswell commented on Nov 9, 2017

    @tacaswell
    Member

    Bumped this to 2.2 because it is not a regression from 2.0

  7. tacaswell commented on Dec 4, 2022

    @tacaswell
    Member

    Retesting this now (3.6.2) , plt.clf() clears the history as I think is correct and I stand by the behavior in step 3 being correct.

    Closing this as it appears fixed to me. I did not bisect to sort out when we fixed it, but I suspect it was 2b0b376 (which resets the nav stack if the axes in the figure change).

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