Skip to content

Commit 0b61cc3

Browse files
jklymakmeeseeksmachine
authored andcommitted
Backport PR matplotlib#25305: DOC: add layout='none' option to Figure constructor
1 parent 83e1a7f commit 0b61cc3

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

lib/matplotlib/figure.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,15 +2415,15 @@ def __init__(self,
24152415
The use of this parameter is discouraged. Please use
24162416
``layout='constrained'`` instead.
24172417
2418-
layout : {'constrained', 'compressed', 'tight', `.LayoutEngine`, None}
2418+
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, \
2419+
None}, default: None
24192420
The layout mechanism for positioning of plot elements to avoid
24202421
overlapping Axes decorations (labels, ticks, etc). Note that
24212422
layout managers can have significant performance penalties.
2422-
Defaults to *None*.
24232423
24242424
- 'constrained': The constrained layout solver adjusts axes sizes
2425-
to avoid overlapping axes decorations. Can handle complex plot
2426-
layouts and colorbars, and is thus recommended.
2425+
to avoid overlapping axes decorations. Can handle complex plot
2426+
layouts and colorbars, and is thus recommended.
24272427
24282428
See :doc:`/tutorials/intermediate/constrainedlayout_guide`
24292429
for examples.
@@ -2437,6 +2437,8 @@ def __init__(self,
24372437
decorations do not overlap. See `.Figure.set_tight_layout` for
24382438
further details.
24392439
2440+
- 'none': Do not use a layout engine.
2441+
24402442
- A `.LayoutEngine` instance. Builtin layout classes are
24412443
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
24422444
accessible by 'constrained' and 'tight'. Passing an instance

lib/matplotlib/pyplot.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,13 +741,38 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
741741
clear : bool, default: False
742742
If True and the figure already exists, then it is cleared.
743743
744-
layout : {'constrained', 'tight', 'compressed', \
745-
`.LayoutEngine`, None}, default: None
744+
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
745+
default: None
746746
The layout mechanism for positioning of plot elements to avoid
747747
overlapping Axes decorations (labels, ticks, etc). Note that layout
748-
managers can measurably slow down figure display. Defaults to *None*
749-
(but see the documentation of the `.Figure` constructor regarding the
750-
interaction with rcParams).
748+
managers can measurably slow down figure display.
749+
750+
- 'constrained': The constrained layout solver adjusts axes sizes
751+
to avoid overlapping axes decorations. Can handle complex plot
752+
layouts and colorbars, and is thus recommended.
753+
754+
See :doc:`/tutorials/intermediate/constrainedlayout_guide`
755+
for examples.
756+
757+
- 'compressed': uses the same algorithm as 'constrained', but
758+
removes extra space between fixed-aspect-ratio Axes. Best for
759+
simple grids of axes.
760+
761+
- 'tight': Use the tight layout mechanism. This is a relatively
762+
simple algorithm that adjusts the subplot parameters so that
763+
decorations do not overlap. See `.Figure.set_tight_layout` for
764+
further details.
765+
766+
- 'none': Do not use a layout engine.
767+
768+
- A `.LayoutEngine` instance. Builtin layout classes are
769+
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
770+
accessible by 'constrained' and 'tight'. Passing an instance
771+
allows third parties to provide their own layout engine.
772+
773+
If not given, fall back to using the parameters *tight_layout* and
774+
*constrained_layout*, including their config defaults
775+
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.
751776
752777
**kwargs
753778
Additional keyword arguments are passed to the `.Figure` constructor.

0 commit comments

Comments
 (0)