Skip to content

DOC: add layout='none' option to Figure constructor #25305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,15 +2420,15 @@ def __init__(self,
The use of this parameter is discouraged. Please use
``layout='constrained'`` instead.

layout : {'constrained', 'compressed', 'tight', `.LayoutEngine`, None}
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, \
None}, default: None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not your fault, but the 'constrained' bullet below has an extra indent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's why it's in bold. I was scratching my head about that...

The layout mechanism for positioning of plot elements to avoid
overlapping Axes decorations (labels, ticks, etc). Note that
layout managers can have significant performance penalties.
Defaults to *None*.

- 'constrained': The constrained layout solver adjusts axes sizes
to avoid overlapping axes decorations. Can handle complex plot
layouts and colorbars, and is thus recommended.
to avoid overlapping axes decorations. Can handle complex plot
layouts and colorbars, and is thus recommended.

See :doc:`/tutorials/intermediate/constrainedlayout_guide`
for examples.
Expand All @@ -2442,6 +2442,8 @@ def __init__(self,
decorations do not overlap. See `.Figure.set_tight_layout` for
further details.

- 'none': Do not use a layout engine.

- A `.LayoutEngine` instance. Builtin layout classes are
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
accessible by 'constrained' and 'tight'. Passing an instance
Expand Down
35 changes: 30 additions & 5 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,38 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
clear : bool, default: False
If True and the figure already exists, then it is cleared.

layout : {'constrained', 'tight', 'compressed', \
`.LayoutEngine`, None}, default: None
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
default: None
The layout mechanism for positioning of plot elements to avoid
overlapping Axes decorations (labels, ticks, etc). Note that layout
managers can measurably slow down figure display. Defaults to *None*
(but see the documentation of the `.Figure` constructor regarding the
interaction with rcParams).
managers can measurably slow down figure display.

- 'constrained': The constrained layout solver adjusts axes sizes
to avoid overlapping axes decorations. Can handle complex plot
layouts and colorbars, and is thus recommended.

See :doc:`/tutorials/intermediate/constrainedlayout_guide`
for examples.

- 'compressed': uses the same algorithm as 'constrained', but
removes extra space between fixed-aspect-ratio Axes. Best for
simple grids of axes.

- 'tight': Use the tight layout mechanism. This is a relatively
simple algorithm that adjusts the subplot parameters so that
decorations do not overlap. See `.Figure.set_tight_layout` for
further details.

- 'none': Do not use a layout engine.

- A `.LayoutEngine` instance. Builtin layout classes are
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
accessible by 'constrained' and 'tight'. Passing an instance
allows third parties to provide their own layout engine.

If not given, fall back to using the parameters *tight_layout* and
*constrained_layout*, including their config defaults
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.

**kwargs
Additional keyword arguments are passed to the `.Figure` constructor.
Expand Down