Bug report
Bug summary
When storing plots as pdf, the colorbar is at the wrong position, off by a small amount:
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
print(matplotlib.__version__)
rng = np.random.default_rng(0)
image = rng.normal(size=(40, 40))
# only happens at this exact figure size....
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(2.976338729763387, 1.4881693648816936), constrained_layout=True)
img1 = ax1.imshow(image)
img2 = ax2.imshow(image)
fig.colorbar(img1, orientation='horizontal', ax=ax1)
fig.colorbar(img2, orientation='horizontal', ax=ax2)
plt.savefig('colorbar.pdf')
Actual outcome
png converted from pdf output using pdftoppm -r 600 -png -singlefile colorbar.pdf colorbar:

Matplotlib version
- Operating system: Manjaro Linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)): 3.4.2
- Matplotlib backend (
print(matplotlib.get_backend())): pdf (since plot saved as pdf)
- Python version: 3.9.5
Bug report
Bug summary
When storing plots as pdf, the colorbar is at the wrong position, off by a small amount:
Code for reproduction
Actual outcome
png converted from pdf output using
pdftoppm -r 600 -png -singlefile colorbar.pdf colorbar:Matplotlib version
import matplotlib; print(matplotlib.__version__)): 3.4.2print(matplotlib.get_backend())): pdf (since plot saved as pdf)