You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repositioned Axes3d do not scale size with Figure size change #20655
If Axes3d was repositioned by set_position() prior to figure size change, it will not adjust its size. Normal axes behave differently.
Code for reproduction
importmatplotlib.pyplotaspldefadjustPos(ax, shift=-0.08):
pos=ax.get_position()
ax.set_position(pos.translated(shift, 0))
#axes gridN=10C=2fig=pl.figure() #default (small) sizefig2=pl.figure()
fig2.set_size_inches(7,2*N)
defadjustPos(ax, shift=-0.08):
pos=ax.get_position()
ax.set_position(pos.translated(shift, 0))
foriiinrange(N):
#add and shift (by zero) normal and 3d axesax=fig.add_subplot(N, C, 1+ii*C)
adjustPos(ax, 0)
ax=fig.add_subplot(N, C, 1+ii*C+1, projection="3d")
adjustPos(ax, 0)
#the same for already large fig2ax=fig2.add_subplot(N, C, 1+ii*C)
adjustPos(ax, 0)
ax=fig2.add_subplot(N, C, 1+ii*C+1, projection="3d")
adjustPos(ax, 0)
fig.savefig("test_original_size.jpg", dpi=300)
fig.set_size_inches(7,2*N)
fig.savefig("test_large_size.jpg", dpi=300)
fig2.savefig("test_big_figure.jpg", dpi=300)
Actual outcome
If axes positions are adjusted by calling set_position(), even if the actual shift is 0, Axes3D will keep its size determined for the original size of figure.
Original figure size (axes do not fit comfortably):
Figure enlarged after axes are created and shifted:
This effect will not take place if set_position() is not called. The issue can be easily avoided by setting figure size ahead of axes creation as done with fig2:
However, I would expect this behaviour regardless of where the figure size is changed.
Matplotlib version
Operating system: Debian GNU/Linux 10
Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.4.2
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
oscargus commentedon Aug 8, 2022
I can confirm this. However, it doesn't hold for the interactive backends, only the ones generating files (both jpg/png and pdf).
To further narrow it down, it seems related to subplots. Using a single axis and reposition it, the size it not identical.
oscargus commentedon Oct 21, 2022
Probably related to #19519
github-actions commentedon Jan 2, 2026
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
rcomer commentedon Oct 16, 2026
I can still reproduce this with current
main.