Skip to content

Commit 00fbb7d

Browse files
committed
subplots and figure docstring changes
1 parent 6665bc7 commit 00fbb7d

File tree

2 files changed

+51
-37
lines changed

2 files changed

+51
-37
lines changed

lib/matplotlib/figure.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,13 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
12541254
"""
12551255
Add a set of subplots to this figure.
12561256
1257+
This utility wrapper makes it convenient to create common layouts of
1258+
subplots in a single call.
1259+
12571260
Parameters
12581261
----------
1259-
nrows, ncols : int, default: 1
1260-
Number of rows/cols of the subplot grid.
1262+
nrows, ncols : int, optional, default: 1
1263+
Number of rows/columns of the subplot grid.
12611264
12621265
sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
12631266
Controls sharing of properties among x (`sharex`) or y (`sharey`)
@@ -1291,25 +1294,27 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
12911294
is always a 2D array containing Axes instances, even if it ends
12921295
up being 1x1.
12931296
1294-
subplot_kw : dict, default: {}
1297+
subplot_kw : dict, optional
12951298
Dict with keywords passed to the
12961299
:meth:`~matplotlib.figure.Figure.add_subplot` call used to create
1297-
each subplots.
1300+
each subplot.
12981301
1299-
gridspec_kw : dict, default: {}
1302+
gridspec_kw : dict, optional
13001303
Dict with keywords passed to the
1301-
:class:`~matplotlib.gridspec.GridSpec` constructor used to create
1304+
`~matplotlib.gridspec.GridSpec` constructor used to create
13021305
the grid the subplots are placed on.
13031306
13041307
Returns
13051308
-------
1306-
ax : single Axes object or array of Axes objects
1307-
The added axes. The dimensions of the resulting array can be
1308-
controlled with the squeeze keyword, see above.
1309+
ax : Axes object or array of Axes objects.
1310+
*ax* can be either a single `~matplotlib.axes.Axes` object or
1311+
an array of Axes objects if more than one subplot was created. The
1312+
dimensions of the resulting array can be controlled with the
1313+
squeeze keyword, see above.
13091314
13101315
See Also
13111316
--------
1312-
pyplot.subplots : pyplot API; docstring includes examples.
1317+
:func:`.pyplot.subplots`: docstring includes examples.
13131318
"""
13141319

13151320
if isinstance(sharex, bool):

lib/matplotlib/pyplot.py

+36-27
Original file line numberDiff line numberDiff line change
@@ -426,43 +426,46 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
426426
`num`.
427427
428428
figsize : tuple of integers, optional, default: None
429-
width, height in inches. If not provided, defaults to rc
430-
figure.figsize.
429+
width, height in inches. If not provided, defaults to
430+
:rc:`figure.figsize` = ``[6.4, 4.8]``.
431431
432432
dpi : integer, optional, default: None
433-
resolution of the figure. If not provided, defaults to rc figure.dpi.
433+
resolution of the figure. If not provided, defaults to
434+
:rc:`figure.dpi` = ``100``.
434435
435436
facecolor :
436-
the background color. If not provided, defaults to rc figure.facecolor.
437+
the background color. If not provided, defaults to
438+
:rc:`figure.facecolor` = ``'w'``.
437439
438440
edgecolor :
439-
the border color. If not provided, defaults to rc figure.edgecolor.
441+
the border color. If not provided, defaults to
442+
:rc:`figure.edgecolor` = ``'w'``.
440443
441444
frameon : bool, optional, default: True
442445
If False, suppress drawing the figure frame.
443446
444-
FigureClass : class derived from matplotlib.figure.Figure
445-
Optionally use a custom Figure instance.
447+
FigureClass : subclass of `~matplotlib.figure.Figure`
448+
Optionally use a custom `.Figure` instance.
446449
447450
clear : bool, optional, default: False
448451
If True and the figure already exists, then it is cleared.
449452
450453
Returns
451454
-------
452-
figure : Figure
453-
The Figure instance returned will also be passed to new_figure_manager
454-
in the backends, which allows to hook custom Figure classes into the
455-
pylab interface. Additional kwargs will be passed to the figure init
456-
function.
455+
figure : `~matplotlib.figure.Figure`
456+
The `.Figure` instance returned will also be passed to new_figure_manager
457+
in the backends, which allows to hook custom `.Figure` classes into the
458+
pyplot interface. Additional kwargs will be passed to the `.Figure`
459+
init function.
457460
458461
Notes
459462
-----
460-
If you are creating many figures, make sure you explicitly call "close"
461-
on the figures you are not using, because this will enable pylab
462-
to properly clean up the memory.
463+
If you are creating many figures, make sure you explicitly call
464+
:func:`.pyplot.close` on the figures you are not using, because this will
465+
enable pyplot to properly clean up the memory.
463466
464-
rcParams defines the default values, which can be modified in the
465-
matplotlibrc file.
467+
`~matplotlib.rcParams` defines the default values, which can be modified
468+
in the matplotlibrc file.
466469
"""
467470

468471
if figsize is None:
@@ -1020,7 +1023,7 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10201023
10211024
squeeze : bool, optional, default: True
10221025
- If True, extra dimensions are squeezed out from the returned
1023-
array of Axes:
1026+
array of `~matplotlib.axes.Axes`:
10241027
10251028
- if only one subplot is constructed (nrows=ncols=1), the
10261029
resulting single Axes object is returned as a scalar.
@@ -1038,20 +1041,19 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10381041
subplot.
10391042
10401043
gridspec_kw : dict, optional
1041-
Dict with keywords passed to the
1042-
:class:`~matplotlib.gridspec.GridSpec` constructor used to create the
1043-
grid the subplots are placed on.
1044+
Dict with keywords passed to the `~matplotlib.gridspec.GridSpec`
1045+
constructor used to create the grid the subplots are placed on.
10441046
10451047
**fig_kw :
1046-
All additional keyword arguments are passed to the :func:`figure` call.
1048+
All additional keyword arguments are passed to the
1049+
:func:`.pyplot.figure` call.
10471050
10481051
Returns
10491052
-------
1050-
fig : :class:`matplotlib.figure.Figure` object
1053+
fig : `~matplotlib.figure.Figure`
10511054
10521055
ax : Axes object or array of Axes objects.
1053-
1054-
ax can be either a single :class:`matplotlib.axes.Axes` object or an
1056+
*ax* can be either a single `~matplotlib.axes.Axes` object or an
10551057
array of Axes objects if more than one subplot was created. The
10561058
dimensions of the resulting array can be controlled with the squeeze
10571059
keyword, see above.
@@ -1098,10 +1100,17 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
10981100
10991101
>>> plt.subplots(2, 2, sharex=True, sharey=True)
11001102
1103+
Creates figure number 10 with a single subplot
1104+
and clears it if it already exists.
1105+
1106+
>>> fig, ax=plt.subplots(num=10, clear=True)
1107+
11011108
See Also
11021109
--------
1103-
figure
1104-
subplot
1110+
:func:`.pyplot.figure`
1111+
:func:`.pyplot.subplot`
1112+
:meth:`.Figure.add_subplot`
1113+
:meth:`.Figure.subplots`
11051114
"""
11061115
fig = figure(**fig_kw)
11071116
axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,

0 commit comments

Comments
 (0)