Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Previous view not always saved when using zoom_pan #27228

Open
@kaostheory78

Description

@kaostheory78

Bug summary

All's in the title.

When having several graphics sharing an axis for the display, the zoom pan module is not always saving the previous view before zooming.
(axes=plt.subplot(sharex=refAxis)

After investigation I think I understand why.
The navigation toolbar pushes the new state only if the _navStack is empty.
I believe the proper check should be :

  • If the navStack is empty or if the current position is not the last one in the navStacj

cf following line of code

ifself._nav_stack()isNone:

Code for reproduction

import matplotlib.pyplot as pltimport numpy as npt = np.arange(0.01, 5.0, 0.01)s1 = np.sin(2 * np.pi * t)ax1 = plt.subplot()plt.plot(t, s1)plt.tick_params('x', labelsize=6)# share x onlyplt.figure()ax2 = plt.subplot(sharex=ax1)plt.plot(t, s1)plt.tick_params('x', labelsize=6)

Step to reproduce:

  1. Create two different figures sharing the same x axis (using sharex attribute for instance)
  2. zoom in the first figure using the navigationToolBar
  3. zoom again in the second figure
  4. Return in the first figure and zoom again
  5. Press back button in the first figure

Expected Outcomes:

  1. two figures displayed
  2. Figure 1 and 2 display thefirst zoomed zone along x axis (zone1)
  3. Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)
  4. Figure 1 and 2 display thethird zoomed zone along x axis (zone3)
  5. Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)

Obersed Outcomes:

  1. two figures displayed
  2. Figure 1 and 2 display thefirst zoomed zone along x axis (zone1)
  3. Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)
  4. Figure 1 and 2 display thethird zoomed zone along x axis (zone3)
  5. Figure 1 and 2 display thefirst zoomed zone along x axis (zone1) ---> Here is not as expected (zone 1 instead of zoom 2 ie previous state before the zoom)

Additional information

Operating system

Windows

Matplotlib Version

3.8

Matplotlib Backend

qtagg

Python version

3.7.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp