From 14154065afcdb920008c85f4b9807c8e07808430 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 1 Jun 2020 21:24:18 +0200 Subject: [PATCH] Update subplot2grid doc to use Figure.add_gridspec, not GridSpec. --- lib/matplotlib/pyplot.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 32f63db834c1..a024ebf7a084 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1295,17 +1295,27 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs): **kwargs Additional keyword arguments are handed to `add_subplot`. + Returns + ------- + an `.axes.SubplotBase` subclass of `~.axes.Axes` (or a subclass of \ +`~.axes.Axes`) + + The axes of the subplot. The returned axes base class depends on the + projection used. It is `~.axes.Axes` if rectilinear projection is used + and `.projections.polar.PolarAxes` if polar projection is used. The + returned axes is then a subplot subclass of the base class. + Notes ----- The following call :: - subplot2grid(shape, loc, rowspan=1, colspan=1) + ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan) is identical to :: - gridspec = GridSpec(shape[0], shape[1]) - subplotspec = gridspec.new_subplotspec(loc, rowspan, colspan) - subplot(subplotspec) + fig = gcf() + gs = fig.add_gridspec(nrows, ncols) + ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan]) """ if fig is None: