-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
status: confirmed bugtopic: geometry managerLayoutEngine, Constrained layout, Tight layoutLayoutEngine, Constrained layout, Tight layout
Description
Bug summary
I used layout=compressed to align colorbar and figure, but after I added fig.suptitle the colorbar is not aligned
Actual outcome
If I do not add "fig.suptitle", the colorbar is aligned with the subfigure

import matplotlib.pyplot as plt
import numpy as np
arr = np.arange(100).reshape((10, 10))
fig, ax = plt.subplots(ncols=2, figsize=(4, 2), layout='compressed')
im0 = ax[0].imshow(arr)
im1 = ax[1].imshow(arr)
plt.colorbar(im0, ax=ax[0])
plt.colorbar(im1, ax=ax[1])
plt.show()
If I add "fig.suptitle", the colorbar is slightly longer than the subfigure

import matplotlib.pyplot as plt
import numpy as np
arr = np.arange(100).reshape((10, 10))
fig, ax = plt.subplots(ncols=2, figsize=(4, 2), layout='compressed')
im0 = ax[0].imshow(arr)
im1 = ax[1].imshow(arr)
plt.colorbar(im0, ax=ax[0])
plt.colorbar(im1, ax=ax[1])
fig.suptitle('Title')
plt.show()
Expected outcome
If I do not add "fig.suptitle", the colorbar should still aligned to the subfigure, while added a title above them
Matplotlib Version
3.10.3
Metadata
Metadata
Assignees
Labels
status: confirmed bugtopic: geometry managerLayoutEngine, Constrained layout, Tight layoutLayoutEngine, Constrained layout, Tight layout