Skip to content

[MNT]: API consistency for Figure layout_engine #29636

Open
@timhoffm

Description

@timhoffm

Summary

Summary

Split out of #24617. Before we can implement this, we need a though API discussion (#24617 (comment)).

Current state:

  • We have figure(..., layout=...)
  • But set/get_layout_engine().

I'm opposed to creating an alias set_layout/set_layout_engine.

We should converge to one name. While layout_engine is more explicit layout seems good enough. If the name would only be used rarely I'd go with the longer option, but since we don't have a layout engine by default, people must often use plt.subplots(..., layout="constrained") and plt.subplots(..., layout_engine="constrained") is way too long to just create a figure.

Semi-OT: I'm tempted to start a discussion whether we can make constrained layout the default. It is what people would want most of the time, and having to always explicitly enable it is a nuissance. Of course it's a significant change and imacts basically all figures created with matplotlib. OTOH it's "only" a shift of some of the graphic elements, which does not affect the visual expression of the figure - I claim most people would not notice. And if you want the previous behavior, you can set the layout engine to none.

Either way, if we want to move forward on the layout topic, we should agree on one name and slowly phase out the other. At least discourage, but possibly pending deprecate.

Proposed fix

No response

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