Skip to content

[ENH]: UserWarning: The figure layout has changed to tight #26535

Closed

Description

@barnakissdr

Problem

plt.tight_layout() gives UserWarning: The figure layout has changed to tight.

That's what tight_layout should do, right? Then why to annoy us with a warning saying that tight_layout did what it was supposed to do?

Proposed solution

Remove UserWarning

Activity

  1. rcomer commented on Aug 16, 2023

    @rcomer
    Member

    Can you say more about the circumstances where you see the warning? If you set up your figure with constrained layout and then called tight_layout, then these two things are mutually exclusive so we throw the warning because we think trying to use both was a mistake. If you are seeing the warning because you called tight_layout twice then that was a mistake in Matplotlib and has been fixed ready for the next release (#26300).

  2. barnakissdr commented on Aug 16, 2023

    @barnakissdr
    Author
  3. rcomer commented on Aug 16, 2023

    @rcomer
    Member

    OK great, are you happy to close this issue then? With version 3.8, you should be able to call tight_layout as many times as you want and the warning should not appear. The release candidate is out on PyPI if you want to try it out.
    https://pypi.org/project/matplotlib/3.8.0rc1/

  4. barnakissdr commented on Aug 16, 2023

    @barnakissdr
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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