Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: layout=compressed conflict with suptitle #30472

Open
@Firestar-Reimu

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

Image
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

Image
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

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /