Skip to content

[Bug]: calling fig.tight_layout multiple times  #26290

Closed
@tacaswell

Description

@tacaswell

Bug summary

Calling fig.tight_layout() multiple times warns.

Code for reproduction

import matplotlib.pyplot as plt

fig = plt.figure()
fig.tight_layout()
fig.tight_layout()

Actual outcome

<ipython-input-9-0981ef8afcc1>:5: UserWarning: The figure layout has changed to tight
  fig.tight_layout()

Expected outcome

no-warning.

Additional information

does not show up in 3.7.1, does show up in 3.7.2. Have not bisected this yet (or checked main).

From looking at the code I suspect
6a82f38 / #25626 / #25624 which is from me 😞 .

xref #25624

I suspect the fix is to not warn if we set the place holder due to fig.tight_layout.

Operating system

Arch

Matplotlib Version

3.7.2

Matplotlib Backend

any

Python version

3.11

Jupyter version

No response

Installation

pip

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