8000 DOC: Recommend constrained_layout over tight_layout (#29584) · matplotlib/matplotlib@293eff8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 293eff8

Browse files
timhoffmMecanerdrcomer
authored
DOC: Recommend constrained_layout over tight_layout (#29584)
* DOC: Recommend constrained_layout over tight_layout Closes #17339 by addressing the remaining open issue #17339 (comment). * Update lib/matplotlib/layout_engine.py Co-authored-by: Mecanerd <joshdonath23@hotmail.com> * Update galleries/users_explain/axes/tight_layout_guide.py Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com> --------- Co-authored-by: Mecanerd <joshdonath23@hotmail.com> Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
1 parent 0b7a88a commit 293eff8

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

galleries/users_explain/axes/tight_layout_guide.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
1010
How to use tight-layout to fit plots within your figure cleanly.
1111
12+
.. tip::
13+
14+
*tight_layout* was the first layout engine in Matplotlib. The more modern
15+
and more capable :ref:`Constrained Layout <constrainedlayout_guide>` should
16+
typically be used instead.
17+
1218
*tight_layout* automatically adjusts subplot params so that the
1319
subplot(s) fits in to the figure area. This is an experimental
1420
feature and may not work for some cases. It only checks the extents
1521
of ticklabels, axis labels, and titles.
1622
17-
An alternative to *tight_layout* is :ref:`constrained_layout
18-
<constrainedlayout_guide>`.
19-
20-
2123
Simple example
2224
==============
2325

lib/matplotlib/layout_engine.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
layout engine while the figure is being created. In particular, colorbars are
1111
made differently with different layout engines (for historical reasons).
1212
13-
Matplotlib supplies two layout engines, `.TightLayoutEngine` and
14-
`.ConstrainedLayoutEngine`. Third parties can create their own layout engine
15-
by subclassing `.LayoutEngine`.
13+
Matplotlib has two built-in layout engines:
14+
15+
- `.TightLayoutEngine` was the first layout engine added to Matplotlib.
16+
See also :ref:`tight_layout_guide`.
17+
- `.ConstrainedLayoutEngine` is more modern and generally gives better results.
18+
See also :ref:`constrainedlayout_guide`.
19+
20+
Third parties can create their own layout engine by subclassing `.LayoutEngine`.
1621
"""
1722

1823
from contextlib import nullcontext

0 commit comments

Comments
 (0)
0