10000 Merge pull request #17550 from anntzer/s2g · matplotlib/matplotlib@9c35cae · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c35cae

Browse files
authored
Merge pull request #17550 from anntzer/s2g
Update subplot2grid doc to use Figure.add_gridspec, not GridSpec.
2 parents 81e27d4 + 1415406 commit 9c35cae

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
@@ -1303,17 +1303,27 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
13031303
is used. The returned axes is then a subplot subclass of the
13041304
base class.
13051305
1306+
Returns
1307+
-------
1308+
an `.axes.SubplotBase` subclass of `~.axes.Axes` (or a subclass of \
1309+
`~.axes.Axes`)
1310+
1311+
The axes of the subplot. The returned axes base class depends on the
1312+
projection used. It is `~.axes.Axes` if rectilinear projection is used
1313+
and `.projections.polar.PolarAxes` if polar projection is used. The
1314+
returned axes is then a subplot subclass of the base class.
1315+
13061316
Notes
13071317
-----
13081318
The following call ::
13091319
1310-
subplot2grid(shape, loc, rowspan=1, colspan=1)
1320+
ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan)
13111321
13121322
is identical to ::
13131323
1314-
gridspec = GridSpec(shape[0], shape[1])
1315-
subplotspec = gridspec.new_subplotspec(loc, rowspan, colspan)
1316-
subplot(subplotspec)
1324+
fig = gcf()
1325+
gs = fig.add_gridspec(nrows, ncols)
1326+
ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan])
13171327
"""
13181328

13191329
if fig is None:

0 commit comments

Comments
 (0)
0