Skip to content

Commit 2f7a58d

Browse files
authored
Merge pull request #17229 from anntzer/subplots_adjust
MNT: Autogenerate subplots_adjust with boilerplate.py.
2 parents ac01f12 + d41803c commit 2f7a58d

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

lib/matplotlib/figure.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -2217,8 +2217,31 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
22172217
def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
22182218
wspace=None, hspace=None):
22192219
"""
2220-
Update the `SubplotParams` with *kwargs* (defaulting to rc when
2221-
*None*), and update the subplot locations.
2220+
Adjust the subplot layout parameters.
2221+
2222+
Unset parameters are left unmodified; initial values are given by
2223+
:rc:`figure.subplot.[name]`.
2224+
2225+
Parameters
2226+
----------
2227+
left : float, optional
2228+
The position of the left edge of the subplots,
2229+
as a fraction of the figure width.
2230+
right : float, optional
2231+
The position of the right edge of the subplots,
2232+
as a fraction of the figure width.
2233+
bottom : float, optional
2234+
The position of the bottom edge of the subplots,
2235+
as a fraction of the figure height.
2236+
top : float, optional
2237+
The position of the top edge of the subplots,
2238+
as a fraction of the figure height.
2239+
wspace : float, optional
2240+
The width of the padding between subplots,
2241+
as a fraction of the average axes width.
2242+
hspace : float, optional
2243+
The height of the padding between subplots,
2244+
as a fraction of the average axes height.
22222245
"""
22232246
if self.get_constrained_layout():
22242247
self.set_constrained_layout(False)

lib/matplotlib/pyplot.py

+10-22
Original file line numberDiff line numberDiff line change
@@ -1287,28 +1287,6 @@ def twiny(ax=None):
12871287
return ax1
12881288

12891289

1290-
def subplots_adjust(left=None, bottom=None, right=None, top=None,
1291-
wspace=None, hspace=None):
1292-
"""
1293-
Tune the subplot layout.
1294-
1295-
The parameter meanings (and suggested defaults) are::
1296-
1297-
left = 0.125 # the left side of the subplots of the figure
1298-
right = 0.9 # the right side of the subplots of the figure
1299-
bottom = 0.1 # the bottom of the subplots of the figure
1300-
top = 0.9 # the top of the subplots of the figure
1301-
wspace = 0.2 # the amount of width reserved for space between subplots,
1302-
# expressed as a fraction of the average axis width
1303-
hspace = 0.2 # the amount of height reserved for space between subplots,
1304-
# expressed as a fraction of the average axis height
1305-
1306-
The actual defaults are controlled by the rc file
1307-
"""
1308-
fig = gcf()
1309-
fig.subplots_adjust(left, bottom, right, top, wspace, hspace)
1310-
1311-
13121290
def subplot_tool(targetfig=None):
13131291
"""
13141292
Launch a subplot tool window for a figure.
@@ -2223,6 +2201,16 @@ def ginput(
22232201
mouse_stop=mouse_stop)
22242202

22252203

2204+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
2205+
@_copy_docstring_and_deprecators(Figure.subplots_adjust)
2206+
def subplots_adjust(
2207+
left=None, bottom=None, right=None, top=None, wspace=None,
2208+
hspace=None):
2209+
return gcf().subplots_adjust(
2210+
left=left, bottom=bottom, right=right, top=top, wspace=wspace,
2211+
hspace=hspace)
2212+
2213+
22262214
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
22272215
@_copy_docstring_and_deprecators(Figure.suptitle)
22282216
def suptitle(t, **kwargs):

tools/boilerplate.py

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def boilerplate_gen():
188188
'gca',
189189
'gci:_gci',
190190
'ginput',
191+
'subplots_adjust',
191192
'suptitle',
192193
'waitforbuttonpress',
193194
)

0 commit comments

Comments
 (0)