Skip to content

Commit 1415406

Browse files
committed
Update subplot2grid doc to use Figure.add_gridspec, not GridSpec.
1 parent 5445d77 commit 1415406

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/matplotlib/pyplot.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,17 +1295,27 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
12951295
**kwargs
12961296
Additional keyword arguments are handed to `add_subplot`.
12971297
1298+
Returns
1299+
-------
1300+
an `.axes.SubplotBase` subclass of `~.axes.Axes` (or a subclass of \
1301+
`~.axes.Axes`)
1302+
1303+
The axes of the subplot. The returned axes base class depends on the
1304+
projection used. It is `~.axes.Axes` if rectilinear projection is used
1305+
and `.projections.polar.PolarAxes` if polar projection is used. The
1306+
returned axes is then a subplot subclass of the base class.
1307+
12981308
Notes
12991309
-----
13001310
The following call ::
13011311
1302-
subplot2grid(shape, loc, rowspan=1, colspan=1)
1312+
ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan)
13031313
13041314
is identical to ::
13051315
1306-
gridspec = GridSpec(shape[0], shape[1])
1307-
subplotspec = gridspec.new_subplotspec(loc, rowspan, colspan)
1308-
subplot(subplotspec)
1316+
fig = gcf()
1317+
gs = fig.add_gridspec(nrows, ncols)
1318+
ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan])
13091319
"""
13101320

13111321
if fig is None:

0 commit comments

Comments
 (0)