Skip to content

[Bug]: plt.tight_layout() after layout='constrained' should at least warn #24387

Closed

Description

@jklymak

If a user does something like

fig, axs = plt.subplots(2, 2, layout='constrained')
..
plt.tight_layout()

tight_layout is called, and constrained_layout is ignored. This was originally done because constrained_layout was experimental. However, people seem to think constrained_layout is not working because they have copy-and-pasted, or reflexively added plt.tight_layout.

I'd propose that we at least warn if plt.tight_layout is called on a figure with an active layout manager. I'd also be open to this being an error.

Activity

  1. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    on Nov 6, 2022
  2. rcomer commented on Feb 6, 2023

    @rcomer
    Member

    Is this closed by #24528?

  3. timhoffm commented on Sep 19, 2024

    @timhoffm
    Member

    Yes.

  4. added this to the v3.7.0 milestone on Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …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