Skip to content

Commit 0d9f766

Browse files
authored
Merge pull request #17535 from timhoffm/doc-subplot2grid
Update docs on subplot2grid / SubplotBase
2 parents c5c12dd + d8d755e commit 0d9f766

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

lib/matplotlib/axes/_subplots.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def __init__(self, fig, *args, **kwargs):
3030
If *nrows*, *ncols*, and *index* are all single digit numbers, then
3131
*args* can be passed as a single 3-digit number (e.g. 234 for
3232
(2, 3, 4)).
33+
34+
**kwargs
35+
Keyword arguments are passed to the Axes (sub)class constructor.
3336
"""
3437

3538
self.figure = fig
@@ -78,15 +81,15 @@ def change_geometry(self, numrows, numcols, num):
7881
self.set_position(self.figbox)
7982

8083
def get_subplotspec(self):
81-
"""Return the SubplotSpec instance associated with the subplot."""
84+
"""Return the `.SubplotSpec` instance associated with the subplot."""
8285
return self._subplotspec
8386

8487
def set_subplotspec(self, subplotspec):
85-
"""Set the SubplotSpec instance associated with the subplot."""
88+
"""Set the `.SubplotSpec`. instance associated with the subplot."""
8689
self._subplotspec = subplotspec
8790

8891
def get_gridspec(self):
89-
"""Return the GridSpec instance associated with the subplot."""
92+
"""Return the `.GridSpec` instance associated with the subplot."""
9093
return self._subplotspec.get_gridspec()
9194

9295
def update_params(self):

lib/matplotlib/figure.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1149,11 +1149,10 @@ def add_axes(self, *args, **kwargs):
11491149
11501150
Returns
11511151
-------
1152-
`~.axes.Axes` (or a subclass of `~.axes.Axes`)
1152+
`~.axes.Axes`, or a subclass of `~.axes.Axes`
11531153
The returned axes class depends on the projection used. It is
1154-
`~.axes.Axes` if rectilinear projection are used and
1155-
`.projections.polar.PolarAxes` if polar projection
1156-
are used.
1154+
`~.axes.Axes` if rectilinear projection is used and
1155+
`.projections.polar.PolarAxes` if polar projection is used.
11571156
11581157
Other Parameters
11591158
----------------
@@ -1309,8 +1308,8 @@ def add_subplot(self, *args, **kwargs):
13091308
13101309
The axes of the subplot. The returned axes base class depends on
13111310
the projection used. It is `~.axes.Axes` if rectilinear projection
1312-
are used and `.projections.polar.PolarAxes` if polar projection
1313-
are used. The returned axes is then a subplot subclass of the
1311+
is used and `.projections.polar.PolarAxes` if polar projection
1312+
is used. The returned axes is then a subplot subclass of the
13141313
base class.
13151314
13161315
Other Parameters

lib/matplotlib/pyplot.py

+22-14
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ def axes(arg=None, **kwargs):
872872
The exact behavior of this function depends on the type:
873873
874874
- *None*: A new full window axes is added using
875-
``subplot(111, **kwargs)``
875+
``subplot(111, **kwargs)``.
876876
- 4-tuple of floats *rect* = ``[left, bottom, width, height]``.
877877
A new axes is added with dimensions *rect* in normalized
878878
(0, 1) units using `~.Figure.add_axes` on the current figure.
@@ -896,11 +896,10 @@ def axes(arg=None, **kwargs):
896896
897897
Returns
898898
-------
899-
`~.axes.Axes` (or a subclass of `~.axes.Axes`)
899+
`~.axes.Axes`, or a subclass of `~.axes.Axes`
900900
The returned axes class depends on the projection used. It is
901-
`~.axes.Axes` if rectilinear projection are used and
902-
`.projections.polar.PolarAxes` if polar projection
903-
are used.
901+
`~.axes.Axes` if rectilinear projection is used and
902+
`.projections.polar.PolarAxes` if polar projection is used.
904903
905904
Other Parameters
906905
----------------
@@ -1023,13 +1022,12 @@ def subplot(*args, **kwargs):
10231022
10241023
Returns
10251024
-------
1026-
an `.axes.SubplotBase` subclass of `~.axes.Axes` (or a subclass of \
1027-
`~.axes.Axes`)
1025+
`.axes.SubplotBase`, or another subclass of `~.axes.Axes`
10281026
10291027
The axes of the subplot. The returned axes base class depends on
10301028
the projection used. It is `~.axes.Axes` if rectilinear projection
1031-
are used and `.projections.polar.PolarAxes` if polar projection
1032-
are used. The returned axes is then a subplot subclass of the
1029+
is used and `.projections.polar.PolarAxes` if polar projection
1030+
is used. The returned axes is then a subplot subclass of the
10331031
base class.
10341032
10351033
Other Parameters
@@ -1278,22 +1276,32 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
12781276

12791277
def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
12801278
"""
1281-
Create an axis at specific location inside a regular grid.
1279+
Create a subplot at a specific location inside a regular grid.
12821280
12831281
Parameters
12841282
----------
12851283
shape : (int, int)
12861284
Number of rows and of columns of the grid in which to place axis.
12871285
loc : (int, int)
12881286
Row number and column number of the axis location within the grid.
1289-
rowspan : int
1287+
rowspan : int, default: 1
12901288
Number of rows for the axis to span to the right.
1291-
colspan : int
1289+
colspan : int, default: 1
12921290
Number of columns for the axis to span downwards.
12931291
fig : `.Figure`, optional
1294-
Figure to place axis in. Defaults to current figure.
1292+
Figure to place the subplot in. Defaults to the current figure.
12951293
**kwargs
1296-
Additional keyword arguments are handed to `add_subplot`.
1294+
Additional keyword arguments are handed to `~.Figure.add_subplot`.
1295+
1296+
Returns
1297+
-------
1298+
`.axes.SubplotBase`, or another subclass of `~.axes.Axes`
1299+
1300+
The axes of the subplot. The returned axes base class depends on
1301+
the projection used. It is `~.axes.Axes` if rectilinear projection
1302+
is used and `.projections.polar.PolarAxes` if polar projection
1303+
is used. The returned axes is then a subplot subclass of the
1304+
base class.
12971305
12981306
Notes
12991307
-----

0 commit comments

Comments
 (0)