Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
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
matplotlib/lib/matplotlib/backend_bases.py
Line 3015 in3958242
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:
- Create two different figures sharing the same x axis (using sharex attribute for instance)
- zoom in the first figure using the navigationToolBar
- zoom again in the second figure
- Return in the first figure and zoom again
- Press back button in the first figure
Expected Outcomes:
- two figures displayed
- Figure 1 and 2 display thefirst zoomed zone along x axis (zone1)
- Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)
- Figure 1 and 2 display thethird zoomed zone along x axis (zone3)
- Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)
Obersed Outcomes:
- two figures displayed
- Figure 1 and 2 display thefirst zoomed zone along x axis (zone1)
- Figure 1 and 2 display thesecond zoomed zone along x axis (zone2)
- Figure 1 and 2 display thethird zoomed zone along x axis (zone3)
- 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