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
Description
Bug summary
Previously, a colorbar axes could be created with a specified aspect ratio and adjustable "box". Now it leaves whitespace either at the ends or on the sides.
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlib.colorbarasmcolorbarfig,axs=plt.subplots(ncols=3,sharey=True)forax,aspectinzip(axs, (20,40,None)):cs=ax.contourf(np.arange(24).reshape((4,6)),levels=[2,4,8,16],extend="both")cax,kw=mcolorbar.make_axes(ax)ifaspectisnotNone:cax.set_aspect(aspect,anchor=(0.8,0.5),adjustable='box')ax.set_title(f"Cbar aspect is{aspect}")else:ax.set_title("No cbar aspect")cbar=fig.colorbar(cs,cax=cax)print(cax.get_aspect(),cax.get_adjustable())fig.savefig("colorbar_aspect.png")
Actual outcome
Expected outcome
Additional information
The result is even worse with 3.5.0: the first 2 colorbars in the example are blank except for the triangles.
Operating system
OS/X
Matplotlib Version
3.5.1
Matplotlib Backend
No response
Python version
3.7.12
Jupyter version
No response
Installation
conda