Movatterモバイル変換


[0]ホーム

URL:


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]: compressed layout setting can be forgotten on second save #24954

Closed
Labels
topic: geometry managerLayoutEngine, Constrained layout, Tight layout
Milestone
@rcomer

Description

@rcomer

Bug summary

I'm not sure whether this is really a bug or I'm just using an inconsistent combination of options. Under some specific circumstances (see below) compressed layout is not applied the second time a figure is saved.

Code for reproduction

importmatplotlibimportmatplotlib.pyplotaspltimportnumpyasnparr=np.arange(100).reshape((10,10))matplotlib.rcParams['figure.constrained_layout.use']=Truefig,ax_dict=plt.subplot_mosaic('AB;AC',figsize=(6,9),width_ratios=[3,2],layout='compressed')forkeyin ["B","C"]:ax_dict[key].imshow(arr)fig.savefig("test1.png",bbox_inches="tight")fig.savefig("test2.png",bbox_inches="tight")

Actual outcome

test1.png
test1

test2.png
test2

Expected outcome

Both images should look like the first.

Additional information

If I do not set thercParams, all is well. If I do not setbbox_inches="tight" in my calls tosavefig, the images are identical (but I have too much white space top and bottom). Maybe there is a better option thanbbox_inches="tight" when using compressed layout?

For context, my real example is a script that makes several figures. For most of them I want constrained layout, so I set that once in thercParams for convenience. Only one figure needs "compressed", and I am saving twice because I want both a png and a pdf. Fixed it in my current example by just reverting thercParams setting for the one figure.

Operating system

RHEL7

Matplotlib Version

3.6.2 and main

Matplotlib Backend

QtAgg

Python version

3.9 and 3.11

Jupyter version

No response

Installation

conda

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp