Bug summary
Updating a GridSpec's width or height ratios after axes have already been added to it has no visible effect — the figure layout silently stays unchanged, even though the internal state is updated correctly.
Code for reproduction
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure()
gs = gridspec.GridSpec(1, 3, figure=fig, width_ratios=[1, 2, 1])
ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[0, 2])
fig.canvas.draw()
print("Before:", round(ax2.get_position().width, 4))
gs.set_width_ratios([1, 1, 1])
fig.canvas.draw()
print("After: ", round(ax2.get_position().width, 4))
fig.savefig('test.png')
plt.show()
Actual outcome
Before: 0.3419
After: 0.3419
Expected outcome
After the ratios are updated, all three axes should become equal width:
Before: 0.3419
After: 0.2279
Additional information
No response
Operating system
Ubuntu 24.04
Matplotlib Version
3.12.0.dev230+g1845e6647
Matplotlib Backend
tkagg
Python version
3.12.3
Jupyter version
No response
Installation
git checkout
Bug summary
Updating a
GridSpec's width or height ratios after axes have already been added to it has no visible effect — the figure layout silently stays unchanged, even though the internal state is updated correctly.Code for reproduction
Actual outcome
Before: 0.3419
After: 0.3419
Expected outcome
After the ratios are updated, all three axes should become equal width:
Before: 0.3419
After: 0.2279
Additional information
No response
Operating system
Ubuntu 24.04
Matplotlib Version
3.12.0.dev230+g1845e6647
Matplotlib Backend
tkagg
Python version
3.12.3
Jupyter version
No response
Installation
git checkout