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
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colorbar as mcolorbar
fig, axs = plt.subplots(ncols=3, sharey=True)
for ax, aspect in zip(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)
if aspect is not None:
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