Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Bug summary
For some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg).
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltx=np.linspace(0,100,100)y=np.linspace(0,100,100)z=x[None, :]**2+y[:,None]**2fig,axarr=plt.subplots(1,2,figsize=(3,2.8789385625),constrained_layout=True,sharey=True)ax=axarr[0]a=ax.pcolormesh(x,y,z,snap=True)fig.colorbar(a,ax=ax,location='top')#ax=axarr[1]a=ax.pcolormesh(x,y,z,snap=True)fig.colorbar(a,ax=ax,location='top')plt.savefig('test_colorbar.pdf')plt.savefig('test_colorbar.svg')plt.savefig('test_colorbar.png',dpi=800)
Actual outcome
Expected outcome
The colorbar should be within its axis, and not shifted upward.
Additional information
- It does not occur when the figure is saved to non-vectorial format (i.e png, etc ..)
- In this case, it does not occur for all figure aspect ratios.
- It was already the case in matplotlib 3.4.3
Operating system
Ubuntu 20
Matplotlib Version
3.5.0
Matplotlib Backend
QtAgg
Python version
3.8.10
Jupyter version
No response
Installation
pip