Skip to content

Commit d53565e

Browse files
committed
DOC: Edits of example
1 parent 6bafe2f commit d53565e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

examples/subplots_axes_and_figures/subpanels.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
`.figure.PanelBase.add_subplot`, or `.figure.PanelBase.subpanels` to make
1212
an array of subpanels. Note that subpanels can also have their own child
1313
subpanels.
14+
15+
.. note::
16+
``subpanel`` is new in v3.4, and the api is still provisional.
17+
1418
"""
1519
import matplotlib.pyplot as plt
1620
import numpy as np

lib/matplotlib/figure.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
99
`SubPanel`
1010
A logical figure inside a figure, usually added to a figure or parent
11-
`SubPanel` with `.add_subpanel` or `.subpanels` methods.
11+
`SubPanel` with `.add_subpanel` or `.subpanels` methods (provisional
12+
API v3.4).
1213
1314
`SubplotParams`
1415
Control the default spacing between subplots.
@@ -1417,6 +1418,35 @@ def subpanels(self, nrows=1, ncols=1, squeeze=True,
14171418
wspace=None, hspace=None,
14181419
width_ratios=None, height_ratios=None,
14191420
**kwargs):
1421+
"""
1422+
Add a subpanel to this figure or subpanel. A subpanel has the same
1423+
artist methods as a figure, and is logically the same as a figure.
1424+
Parameters
1425+
----------
1426+
nrows, ncols : int, default: 1
1427+
Number of rows/columns of the subpanel grid.
1428+
1429+
squeeze : boolean, default: True
1430+
If True, extra dimensions are squeezed out from the returned
1431+
array of subpanels.
1432+
1433+
wspace, hspace : float, default: None
1434+
The amount of width/height reserved for space between subpanels,
1435+
expressed as a fraction of the average subpanel width.
1436+
If not given, the values will be inferred from a figure or
1437+
rcParams when necessary. See also `GridSpec.get_subplot_params`.
1438+
1439+
width_ratios : array-like of length *ncols*, optional
1440+
Defines the relative widths of the columns. Each column gets a
1441+
relative width of ``width_ratios[i] / sum(width_ratios)``.
1442+
If not given, all columns will have the same width.
1443+
1444+
height_ratios : array-like of length *nrows*, optional
1445+
Defines the relative heights of the rows. Each column gets a
1446+
relative height of ``height_ratios[i] / sum(height_ratios)``.
1447+
If not given, all rows will have the same height.
1448+
1449+
"""
14201450
gs = GridSpec(nrows=nrows, ncols=ncols, figure=self,
14211451
wspace=wspace, hspace=hspace,
14221452
width_ratios=width_ratios,

0 commit comments

Comments
 (0)