Skip to content

Commit 9b304a0

Browse files
committed
Make params to pyplot.tight_layout keyword-only.
This will allow just autogen'ing pyplot.tight_layout with boilerplate.py after the deprecation elapses (Figure.tight_layout currently has a `delete_parameter()` on its first parameter, *renderer*; after *that* deprecation elapses all following parameters become keyword only). Also some docstring rewordings.
1 parent 6372f1d commit 9b304a0

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

doc/api/api_changes_3.3/deprecations.rst

+5-4
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

+7-8
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,7 @@ def execute_constrained_layout(self, renderer=None):
24142414
def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24152415
rect=None):
24162416
"""
2417-
Automatically adjust subplot parameters to give specified padding.
2417+
Adjust the padding between and around subplots.
24182418
24192419
To exclude an artist on the axes from the bounding box calculation
24202420
that determines the subplot parameters (i.e. legend, or annotation),
@@ -2424,16 +2424,15 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24242424
----------
24252425
renderer : subclass of `~.backend_bases.RendererBase`, optional
24262426
Defaults to the renderer for the figure. Deprecated.
2427-
pad : float, optional
2427+
pad : float, default: 1.08
24282428
Padding between the figure edge and the edges of subplots,
24292429
as a fraction of the font size.
2430-
h_pad, w_pad : float, optional
2430+
h_pad, w_pad : float, default: *pad*
24312431
Padding (height/width) between edges of adjacent subplots,
2432-
as a fraction of the font size. Defaults to *pad*.
2433-
rect : tuple (left, bottom, right, top), optional
2434-
A rectangle (left, bottom, right, top) in the normalized
2435-
figure coordinate that the whole subplots area (including
2436-
labels) will fit into. Default is (0, 0, 1, 1).
2432+
as a fraction of the font size.
2433+
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1)
2434+
A rectangle in normalized figure coordinates into which the whole
2435+
subplots area (including labels) will fit.
24372436
24382437
See Also
24392438
--------

lib/matplotlib/pyplot.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1328,22 +1328,23 @@ def subplot_tool(targetfig=None):
13281328
return SubplotTool(targetfig, toolfig)
13291329

13301330

1331+
# After deprecation elapses, this can be autogenerated by boilerplate.py.
1332+
@cbook._make_keyword_only("3.3", "pad")
13311333
def tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None):
13321334
"""
1333-
Automatically adjust subplot parameters to give specified padding.
1335+
Adjust the padding between and around subplots.
13341336
13351337
Parameters
13361338
----------
1337-
pad : float
1339+
pad : float, default: 1.08
13381340
Padding between the figure edge and the edges of subplots,
13391341
as a fraction of the font size.
1340-
h_pad, w_pad : float, optional
1342+
h_pad, w_pad : float, default: *pad*
13411343
Padding (height/width) between edges of adjacent subplots,
1342-
as a fraction of the font size. Defaults to *pad*.
1344+
as a fraction of the font size.
13431345
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1)
1344-
A rectangle (left, bottom, right, top) in the normalized
1345-
figure coordinate that the whole subplots area (including
1346-
labels) will fit into.
1346+
A rectangle in normalized figure coordinates into which the whole
1347+
subplots area (including labels) will fit.
13471348
"""
13481349
gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
13491350

0 commit comments

Comments
 (0)