[ENH]: Consider using a layout engine by default · Issue #31976 · matplotlib/matplotlib · GitHub
Skip to content

[ENH]: Consider using a layout engine by default #31976

Description

@timhoffm

Problem

By default, Axes are placed at hard-coded positions, which may result in cut-off/overlapping labels.
The recommendation is therefore to use constrained_layout.

This is a usability issue: Bad placement should not happen by default. And manual fixes such as tuning subplot params or explicitly activating a layout engine are cumbersome.

Proposed solution

We should consider activating constrained_layout by default. For most users, having a good layout by default is much more important than exact reproducibility. If you want the old behavior, you can always set figure(..., layout=None / fig.set_layout_engine(None).

This is a classical trade-off between better defaults and full backward-compatibility. There's no clear answer but IMHO it's worth discussing whether the full backward-compatibility for placement is a stronger argument than better usability.

Unfortunately, there is no smooth transition path with a suitable runtime warning. I think the best we could do is to make a statement on upcoming changes in the release notes. At least people wo read that can then can already switch to layout=None, when positioning repoducibility is important. Then, introduce the changes early in one upcoming release cycle, so that people testing against main will notice changes before the change is released.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions