Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7da6e48

Browse files
authored
Merge pull request #25305 from rcomer/layout-options
DOC: add layout='none' option to Figure constructor
2 parents 2f55cd5 + 2d3cd47 commit 7da6e48

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
@@ -2420,15 +2420,15 @@ def __init__(self,
24202420
The use of this parameter is discouraged. Please use
24212421
``layout='constrained'`` instead.
24222422
2423-
layout : {'constrained', 'compressed', 'tight', `.LayoutEngine`, None}
2423+
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, \
2424+
None}, default: None
24242425
The layout mechanism for positioning of plot elements to avoid
24252426
overlapping Axes decorations (labels, ticks, etc). Note that
24262427
layout managers can have significant performance penalties.
2427-
Defaults to *None*.
24282428
24292429
- 'constrained': The constrained layout solver adjusts axes sizes
2430-
to avoid overlapping axes decorations. Can handle complex plot
2431-
layouts and colorbars, and is thus recommended.
2430+
to avoid overlapping axes decorations. Can handle complex plot
2431+
layouts and colorbars, and is thus recommended.
24322432
24332433
See :doc:`/tutorials/intermediate/constrainedlayout_guide`
24342434
for examples.
@@ -2442,6 +2442,8 @@ def __init__(self,
24422442
decorations do not overlap. See `.Figure.set_tight_layout` for
24432443
further details.
24442444
2445+
- 'none': Do not use a layout engine.
2446+
24452447
- A `.LayoutEngine` instance. Builtin layout classes are
24462448
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
24472449
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
@@ -740,13 +740,38 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
740740
clear : bool, default: False
741741
If True and the figure already exists, then it is cleared.
742742
743-
layout : {'constrained', 'tight', 'compressed', \
744-
`.LayoutEngine`, None}, default: None
743+
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
744+
default: None
745745
The layout mechanism for positioning of plot elements to avoid
746746
overlapping Axes decorations (labels, ticks, etc). Note that layout
747-
managers can measurably slow down figure display. Defaults to *None*
748-
(but see the documentation of the `.Figure` constructor regarding the
749-
interaction with rcParams).
747+
managers can measurably slow down figure display.
748+
749+
- 'constrained': The constrained layout solver adjusts axes sizes
750+
to avoid overlapping axes decorations. Can handle complex plot
751+
layouts and colorbars, and is thus recommended.
752+
753+
See :doc:`/tutorials/intermediate/constrainedlayout_guide`
754+
for examples.
755+
756+
- 'compressed': uses the same algorithm as 'constrained', but
757+
removes extra space between fixed-aspect-ratio Axes. Best for
758+
simple grids of axes.
759+
760+
- 'tight': Use the tight layout mechanism. This is a relatively
761+
simple algorithm that adjusts the subplot parameters so that
762+
decorations do not overlap. See `.Figure.set_tight_layout` for
763+
further details.
764+
765+
- 'none': Do not use a layout engine.
766+
767+
- A `.LayoutEngine` instance. Builtin layout classes are
768+
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
769+
accessible by 'constrained' and 'tight'. Passing an instance
770+
allows third parties to provide their own layout engine.
771+
772+
If not given, fall back to using the parameters *tight_layout* and
773+
*constrained_layout*, including their config defaults
774+
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.
750775
751776
**kwargs
752777
Additional keyword arguments are passed to the `.Figure` constructor.

0 commit comments

Comments
 (0)