Skip to content

toolbar.update() breaks history #9974

Closed
@Nodd

Description

@Nodd

Bug report

Bug summary

I'm looking for resetting the zoom and pan history of interactve browsing. Using toolbar.update() breaks the interactive history, it's not possible to go back to the previous axis state.

Code for reproduction

Run this code in python a console:

from matplotlib import pyplot as plt
f = plt.figure()
plt.plot([1, 2, 5])
plt.show(block=False)
f.canvas.toolbar._views._elements  # One element
f.canvas.toolbar._positions._elements  # One element
f.canvas.toolbar.update()
f.canvas.toolbar._views._elements  # Empty !
f.canvas.toolbar._positions._elements  # Empty !
# Zoom once
# Try to go back using the home button or back arrow

Actual outcome

The view doesn't change when pressing home button or back arrow

Expected outcome

I expect to be able to got back to the state the plot was in when f.canvas.toolbar.update() was called, but since the history is completely empty, there is no state to go back to. I think the current state should be added right after clearing the history. Is it possible to do it manually in the meantime ?

Matplotlib version

  • Operating system: Arch Linux
  • Matplotlib version: 2.1.0-1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.3
  • Jupyter version (if applicable):
  • Other libraries:

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