Description
Bug summary
When pushing the home button the subplots sometimes get larger and larger, sometimes smaller and smaller and sometimes stay in the correct size. The code and procedure below trigger it for me everytime in both QT5 and tkinter but other use cases has also triggered it but much more randomly
import matplotlib.pyplot as plt
import numpy as np
fig=plt.figure(1)
fig.clf()
N=3
for i in range(N*N):
fig.add_subplot(N,N,i+1).plot(np.random.randn(10000))
fig.set_tight_layout(True)
- zoom in one of the subplots
- push the home button
- resize the plot window
- push the home button
- push the home more times get an even worse plot
(it can also be done with the backward and forward buttons).
The subplot plots starts to overlap for me with this procedure.
A new draw or zoom results in a correct plot which I found kind of weird.
I tried to figure out what causes the problem and I think that the problem is in
backend_bases
, line 3100, _update_view()
def _update_view(self):
"""Update the viewlim and position from the view and
position stack for each axes.
"""
nav_info = self._nav_stack()
if nav_info is None:
return
# Retrieve all items at once to avoid any risk of GC deleting an Axes
# while in the middle of the loop below.
items = list(nav_info.items())
for ax, (view, (pos_orig, pos_active)) in items:
ax._set_view(view)
# Restore both the original and modified positions
ax._set_position(pos_orig, 'original')
ax._set_position(pos_active, 'active')
self.canvas.draw_idle()
and due to the lines
ax._set_position(pos_orig, 'original')
ax._set_position(pos_active, 'active')
The home button seems to (almost) work as expected if those lines are commented out. Almost because the view seems to change a little when I push the home button the first time.
Matplotlib 2.2.2
python 3.6.3
IPython 6.1.0
windows 10
installed with conda