Skip to content

Reset view not working in interactive TkAgg backend #9764

Closed

Description

@j4321

Bug report

When using TkAgg in interactive mode, the 'reset view' and 'back to previous view' buttons do not work. However, everything works fine when I am not in interactive mode or using Qt5Agg.

Code for reproduction

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.ion()
plt.plot(range(10))

Then I zoom in and click on 'reset view' / 'back to previous view' and nothing happens. This happens both in the python command line and the jupyter qt console.

However, if I do the same but with

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.ioff()
plt.plot(range(10))
plt.show()

then both buttons work. It is specific to the TkAgg backend because the interactive mode works fine with Qt5Agg.

Matplotlib version

  • Operating system: Archlinux
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.3
  • Jupyter version (if applicable): 4.1.0

I installed python and matplotlib from the official archlinux repository.

Activity

  1. j4321 commented on Nov 21, 2017

    @j4321
    Author

    I have looked a little bit in this bug, and I have noticed the following:

    With TkAgg in interactive mode:

    import matplotlib
    matplotlib.use('TkAgg')
    import matplotlib.pyplot as plt
    plt.ion()
    fig = plt.figure()
    plt.plot(range(10))
    print(fig.canvas.toolbar._views._pos, fig.canvas.toolbar._views._elements)

    fig.canvas.toolbar._views._elements is initially [] and fig.canvas.toolbar._views._pos is -1,
    while in non-interactive mode or with the Qt5Agg, fig.canvas.toolbar._views._elements is not empty and fig.canvas.toolbar._views._pos is 0.

  2. QuLogic commented on Mar 27, 2020

    @QuLogic
    Member

    I believe this is fixed in 2.1.1, by #9359.

  3. added this to the v2.1.1 milestone on Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions