Skip to content

Commit 902502c

Browse files
committed
Improve documentation of SubplotGrid methods
1 parent 5a6da08 commit 902502c

6 files changed

Lines changed: 136 additions & 102 deletions

File tree

docs/basics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
# figures with more than one column and row, a 1D `~numpy.ndarray` for single-column or
340340
# row figures, or an `~matplotlib.axes.Axes` for single-subplot figures. In ProPlot,
341341
# `~proplot.figure.Figure.subplots` returns a `~proplot.gridspec.SubplotGrid` that
342-
# unifies these three possible return values:
342+
# unifies these possible return values:
343343
#
344344
# * `~proplot.gridspec.SubplotGrid` permits array-like 2D indexing, e.g.
345345
# ``axs[1, 0]``. Indexing the `~proplot.gridspec.SubplotGrid` is similar
@@ -388,7 +388,6 @@
388388
axs[1, :1].format(fc='sky blue')
389389
axs[-1, -1].format(fc='gray2', grid=False)
390390

391-
392391
# %% [raw] raw_mimetype="text/restructuredtext"
393392
# .. _ug_rc:
394393
#

proplot/axes/base.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@
162162

163163

164164
# Inset docstring
165+
# NOTE: Used by SubplotGrid.inset_axes
165166
_inset_docstring = """
166-
Return an inset `CartesianAxes`. This is similar to the builtin
167-
`~matplotlib.axes.Axes.inset_axes` but includes some extra options.
167+
Add an inset axes.
168+
This is similar to `matplotlib.axes.Axes.inset_axes`.
168169
169170
Parameters
170171
----------
@@ -187,6 +188,11 @@
187188
zoom_kw : dict, optional
188189
Passed to `~Axes.indicate_inset_zoom`.
189190
191+
Returns
192+
-------
193+
proplot.axes.Axes
194+
The inset axes.
195+
190196
Other parameters
191197
----------------
192198
**kwargs
@@ -196,6 +202,7 @@
196202

197203

198204
# Panel docstring
205+
# NOTE: Used by SubplotGrid.panel_axes
199206
_panel_loc_docstring = """
200207
========== =====================
201208
Location Valid keys
@@ -207,7 +214,7 @@
207214
========== =====================
208215
"""
209216
_panel_docstring = """
210-
Return a panel drawn along the edge of this axes.
217+
Add a panel along the edge of the axes.
211218
212219
Parameters
213220
----------
@@ -235,7 +242,7 @@
235242
236243
Returns
237244
-------
238-
`~proplot.axes.CartesianAxes`
245+
proplot.axes.CartesianAxes
239246
The panel axes.
240247
"""
241248
docstring._snippet_manager['axes.panel_loc'] = _panel_loc_docstring
@@ -320,11 +327,10 @@
320327
figtitle
321328
Alias for `suptitle`.
322329
suptitle : str, optional
323-
The figure "super" title, centered between the left edge of
324-
the lefmost column of subplots and the right edge of the rightmost
325-
column of subplots, and automatically offset above figure titles.
326-
This is an improvement on matplotlib's "super" title, which just
327-
centers the text between figure edges.
330+
The figure "super" title, centered between the left edge of the lefmost
331+
column of subplots and the right edge of the rightmost column of subplots, and
332+
automatically offset above figure titles. This is an improvement on matplotlib's
333+
"super" title, which just centers the text between figure edges.
328334
suptitlepad : float, optional
329335
The padding between the super title and the axes content in arbitrary
330336
units (default is points). Default is :rcraw:`suptitle.pad`.
@@ -1315,9 +1321,8 @@ def format(
13151321
**kwargs
13161322
):
13171323
"""
1318-
Modify the axes title(s), the a-b-c label, row and column labels, and
1319-
the figure title. Called by the `~proplot.axes.CartesianAxes`,
1320-
`~proplot.axes.PolarAxes`, and `~proplot.axes.GeoAxes` ``format`` methods.
1324+
Format the a-b-c label, axes title(s), and background
1325+
patch, and call `proplot.figure.Figure.format`.
13211326
13221327
Parameters
13231328
----------
@@ -1330,20 +1335,20 @@ def format(
13301335
13311336
Important
13321337
---------
1333-
The `abc`, `abcstyle`, `abcloc`, `titleloc`, `titleabove`, `titlepad`,
1334-
`abctitlepad`, `leftlabelpad`, `toplabelpad`, `rightlabelpad`, and
1335-
`bottomlabelpad` keywords are :ref:`configuration settings <ug_config>`.
1336-
We explicitly document these arguments here because it is very common to change
1337-
them. But many :ref:`other configuration settings <ug_format>` can be passed
1338-
to ``format`` too.
1338+
`abc`, `abcstyle`, `abcloc`, `titleloc`, `titleabove`, `titlepad`, and
1339+
`abctitlepad` are actually :ref:`configuration settings <ug_config>`.
1340+
We explicitly document these arguments here because it is common to
1341+
change them for specific axes. But many :ref:`other configuration
1342+
settings <ug_format>` can be passed to ``format`` too.
13391343
13401344
See also
13411345
--------
1342-
proplot.config.Configurator.context
13431346
proplot.axes.CartesianAxes.format
13441347
proplot.axes.PolarAxes.format
13451348
proplot.axes.GeoAxes.format
13461349
proplot.figure.Figure.format
1350+
proplot.gridspec.SubplotGrid.format
1351+
proplot.config.Configurator.context
13471352
"""
13481353
skip_figure = kwargs.pop('skip_figure', False) # internal keyword arg
13491354
rc_kw, rc_mode, kwargs = _parse_format(**kwargs)
@@ -1493,9 +1498,10 @@ def inset_axes(
14931498

14941499
def indicate_inset_zoom(self, **kwargs):
14951500
"""
1496-
Draw lines indicating the zoom range of the inset axes. This is similar
1497-
to the builtin `~matplotlib.axes.Axes.indicate_inset_zoom` except
1498-
lines are *refreshed* at draw-time. This is also called automatically
1501+
Draw lines indicating the zoom range of the inset axes. Must be
1502+
called from the inset axes rather than the parent axes. This is
1503+
similar to `matplotlib.axes.Axes.indicate_inset_zoom` except line
1504+
positions are refreshed at drawtime. This is called automatically
14991505
when ``zoom=True`` is passed to `~Axes.inset_axes`.
15001506
15011507
Parameters
@@ -1508,7 +1514,7 @@ def indicate_inset_zoom(self, **kwargs):
15081514
The line style for the zoom lines and box outline.
15091515
ec, edgecolor : color-spec, optional
15101516
The color of the zoom lines and box outline.
1511-
capstyle : {'butt', 'round', 'projecting'}
1517+
cs, capstyle : {'butt', 'round', 'projecting'}
15121518
The cap style for the zoom lines and box outline.
15131519
zorder : float, optional
15141520
The `zorder <https://matplotlib.org/stable/gallery/misc/zorder_demo.html>`__

proplot/axes/cartesian.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,23 @@
3838
{args} : optional
3939
Prepended with ``'{x}'`` and passed to `Axes.format`.
4040
41+
Returns
42+
-------
43+
CartesianAxes
44+
The new axes.
45+
4146
Note
4247
----
4348
This enforces the following default settings:
4449
45-
* Places the old *{x}* axis on the {x1} and the new *{x}*
50+
* Places the old {x} axis on the {x1} and the new {x}
4651
axis on the {x2}.
4752
* Makes the old {x2} spine invisible and the new {x1}, {y1},
4853
and {y2} spines invisible.
49-
* Adjusts the *{x}* axis tick, tick label, and axis label positions
54+
* Adjusts the {x} axis tick, tick label, and axis label positions
5055
according to the visible spine positions.
51-
* Syncs the old and new *{y}* axis limits and scales, and makes the
52-
new *{y}* axis labels invisible.
56+
* Syncs the old and new {y} axis limits and scales, and makes the
57+
new {y} axis labels invisible.
5358
"""
5459
_shared_x_keys = dict(
5560
x='x', x1='bottom', x2='top',
@@ -65,29 +70,36 @@
6570
)
6671

6772
# Alt docstrings
73+
# NOTE: Used by SubplotGrid.altx
6874
_alt_descrip = """
69-
Return an axes in the same location as this one but whose {x}
70-
axis is on the {x2}. This is an alias and more intuitive name
71-
for `~CartesianAxes.twin{y}`, which generates two *{x}* axes
72-
with a shared ("twin") *{y}* axes.
75+
Add an axes locked to the same location with a
76+
distinct {x} axis.
77+
This is an alias and possibly more intuitive name for
78+
`~CartesianAxes.twin{y}`, which generates two {x} axes
79+
with a shared ("twin") {y} axes.
7380
"""
7481
_alt_docstring = _shared_docstring % {'descrip': _alt_descrip, 'extra': ''}
7582
docstring._snippet_manager['axes.altx'] = _alt_docstring.format(**_shared_x_keys)
7683
docstring._snippet_manager['axes.alty'] = _alt_docstring.format(**_shared_y_keys)
7784

7885
# Twin docstrings
86+
# NOTE: Used by SubplotGrid.twinx
7987
_twin_descrip = """
80-
Return an axes in the same location as this one but whose {x}
81-
axis is on the {x2}. Mimics `matplotlib.axes.Axes.twin{y}`.
88+
Add an axes locked to the same location with a
89+
distinct {x} axis.
90+
This builds upon `matplotlib.axes.Axes.twin{y}`.
8291
"""
8392
_twin_docstring = _shared_docstring % {'descrip': _twin_descrip, 'extra': ''}
8493
docstring._snippet_manager['axes.twinx'] = _twin_docstring.format(**_shared_y_keys)
8594
docstring._snippet_manager['axes.twiny'] = _twin_docstring.format(**_shared_x_keys)
8695

8796
# Dual docstrings
97+
# NOTE: Used by SubplotGrid.dualx
8898
_dual_descrip = """
89-
Return a secondary *{x}* axis for denoting equivalent *{x}*
90-
coordinates in *alternate units*.
99+
Add an axes locked to the same location whose {x} axis denotes
100+
equivalent coordinates in alternate units.
101+
This is an alternative to `matplotlib.axes.Axes.secondary_{x}axis` with
102+
additional convenience features.
91103
"""
92104
_dual_extra = """
93105
funcscale : callable, 2-tuple of callables, or scale-spec
@@ -801,6 +813,7 @@ def format(
801813
See also
802814
--------
803815
proplot.axes.Axes.format
816+
proplot.figure.Figure.format
804817
proplot.config.Configurator.context
805818
806819
Note

proplot/axes/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
%(plot.args_1d_shared)s
128128
order : {{'C', 'F'}}, optional
129129
If ``'C'`` (C-style row-major order), `z` coordinates should be shaped
130-
``(y, x)``. If ``'F'`` (Fortran-style column-major order) `z` coordinates
130+
``(y, x)``. If ``'F'`` (fortran-style column-major order) `z` coordinates
131131
should be shaped ``(x, y)``. Default is ``'C'``.
132132
globe : bool, optional
133133
For `proplot.axes.GeoAxes` only. Whether to enforce global coverage.

proplot/figure.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,28 +1411,38 @@ def format(
14111411
rowlabels=None, collabels=None, **kwargs, # aliases
14121412
):
14131413
"""
1414-
Call the ``format`` command for the input axes or
1415-
for every subplot in the figure.
1414+
Format the figure labels and title and call ``format`` for
1415+
the input axes. By default the numbered subplots are used.
14161416
14171417
Parameters
14181418
----------
14191419
axs : sequence of `~proplot.axes.Axes`, optional
1420-
A sequence of axes. By default the numbered subplots are used.
1420+
The axes to format.
14211421
%(figure.format)s
14221422
14231423
Other parameters
14241424
----------------
14251425
%(axes.format)s
14261426
%(axes.rc)s
14271427
**kwargs
1428-
Passed to the ``format`` command of each axes.
1428+
Passed to the projection-specific ``format`` command for each axes.
1429+
1430+
Important
1431+
---------
1432+
`leftlabelpad`, `toplabelpad`, `rightlabelpad`, and `bottomlabelpad`
1433+
keywords are actually :ref:`configuration settings <ug_config>`.
1434+
We explicitly document these arguments here because it is common to
1435+
change them for specific figures. But many :ref:`other configuration
1436+
settings <ug_format>` can be passed to ``format`` too.
14291437
14301438
See also
14311439
--------
14321440
proplot.axes.Axes.format
14331441
proplot.axes.CartesianAxes.format
14341442
proplot.axes.PolarAxes.format
14351443
proplot.axes.GeoAxes.format
1444+
proplot.gridspec.SubplotGrid.format
1445+
proplot.config.Configurator.context
14361446
"""
14371447
# Initiate context block
14381448
rc_kw, rc_mode, kwargs = _parse_format(**kwargs)

0 commit comments

Comments
 (0)