Skip to content

Commit 355cd3d

Browse files
authored
Merge pull request #17228 from anntzer/tlkwo
Make params to pyplot.tight_layout keyword-only.
2 parents 7ccc2d2 + 9b304a0 commit 355cd3d

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,11 @@ replaced by calls to ``draw_idle()`` on the corresponding canvas.
460460
The ``add_checker`` and ``check_update`` methods and ``update_dict`` attribute
461461
of `.ScalarMappable` are deprecated.
462462

463-
``ColorbarBase`` parameters will become keyword-only
464-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465-
All parameters of ``ColorbarBase``, except for the first (*ax*), will become
466-
keyword-only, consistently with ``Colorbar``.
463+
`.pyplot.tight_layout` and ``ColorbarBase`` parameters will become keyword-only
464+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465+
All parameters of `.pyplot.tight_layout` and all parameters of ``ColorbarBase``
466+
except for the first (*ax*) will become keyword-only, consistently with
467+
`.Figure.tight_layout` and ``Colorbar``, respectively.
467468

468469
`.Axes.pie` radius and startangle
469470
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/figure.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ def execute_constrained_layout(self, renderer=None):
24372437
def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24382438
rect=None):
24392439
"""
2440-
Automatically adjust subplot parameters to give specified padding.
2440+
Adjust the padding between and around subplots.
24412441
24422442
To exclude an artist on the axes from the bounding box calculation
24432443
that determines the subplot parameters (i.e. legend, or annotation),
@@ -2447,16 +2447,15 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24472447
----------
24482448
renderer : subclass of `~.backend_bases.RendererBase`, optional
24492449
Defaults to the renderer for the figure. Deprecated.
2450-
pad : float, optional
2450+
pad : float, default: 1.08
24512451
Padding between the figure edge and the edges of subplots,
24522452
as a fraction of the font size.
2453-
h_pad, w_pad : float, optional
2453+
h_pad, w_pad : float, default: *pad*
24542454
Padding (height/width) between edges of adjacent subplots,
2455-
as a fraction of the font size. Defaults to *pad*.
2456-
rect : tuple (left, bottom, right, top), optional
2457-
A rectangle (left, bottom, right, top) in the normalized
2458-
figure coordinate that the whole subplots area (including
2459-
labels) will fit into. Default is (0, 0, 1, 1).
2455+
as a fraction of the font size.
2456+
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1)
2457+
A rectangle in normalized figure coordinates into which the whole
2458+
subplots area (including labels) will fit.
24602459
24612460
See Also
24622461
--------

lib/matplotlib/pyplot.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,22 +1306,23 @@ def subplot_tool(targetfig=None):
13061306
return SubplotTool(targetfig, toolfig)
13071307

13081308

1309+
# After deprecation elapses, this can be autogenerated by boilerplate.py.
1310+
@cbook._make_keyword_only("3.3", "pad")
13091311
def tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None):
13101312
"""
1311-
Automatically adjust subplot parameters to give specified padding.
1313+
Adjust the padding between and around subplots.
13121314
13131315
Parameters
13141316
----------
1315-
pad : float
1317+
pad : float, default: 1.08
13161318
Padding between the figure edge and the edges of subplots,
13171319
as a fraction of the font size.
1318-
h_pad, w_pad : float, optional
1320+
h_pad, w_pad : float, default: *pad*
13191321
Padding (height/width) between edges of adjacent subplots,
1320-
as a fraction of the font size. Defaults to *pad*.
1322+
as a fraction of the font size.
13211323
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1)
1322-
A rectangle (left, bottom, right, top) in the normalized
1323-
figure coordinate that the whole subplots area (including
1324-
labels) will fit into.
1324+
A rectangle in normalized figure coordinates into which the whole
1325+
subplots area (including labels) will fit.
13251326
"""
13261327
gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
13271328

0 commit comments

Comments
 (0)