8000 constrained_layout + fixed-aspect axes + bbox_inches="tight" · Issue #19339 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
constrained_layout + fixed-aspect axes + bbox_inches="tight" #19339
Closed
@anntzer

Description

@anntzer

Bug report

Bug summary

constrained_layout, fixed aspect axes (e.g. from imshow), and savefig(bbox_inches="tight") don't play well together.

Code for reproduction

fig = plt.figure(constrained_layout=True)
fig.add_subplot().imshow(np.random.rand(10, 10))
fig.savefig("/tmp/out.png", bbox_inches="tight")

Actual outcome

out

The axes are cropped, and the aspect=1 is lost (pixels are not square anymore, but slightly elongated).

Expected outcome

Not the above.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): HEAD
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 39
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0