Skip to content

Commit b2e1b9d

Browse files
authored
Fix some links for docs (#341)
* Fix some links for docs * Add show to remove output from jupytext and fix module link * fix more links * rcParams as :data:
1 parent bf45b83 commit b2e1b9d

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

docs/basics.py

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
#
2727
# UltraPlot works by `subclassing
2828
# <https://docs.python.org/3/tutorial/classes.html#inheritance>`__
29-
# three fundamental matplotlib classes: :class:`ultraplot.figure.Figure` replaces
30-
# :class:`matplotlib.figure.Figure`, :class:`ultraplot.axes.Axes` replaces :class:`matplotlib.axes.Axes`,
31-
# and :class:`ultraplot.gridspec.GridSpec` replaces :class:`matplotlib.gridspec.GridSpec`
29+
# three fundamental matplotlib classes: :class:`~ultraplot.figure.Figure` replaces
30+
# :class:`matplotlib.figure.Figure`, :class:`~ultraplot.axes.Axes` replaces :class:`matplotlib.axes.Axes`,
31+
# and :class:`~ultraplot.gridspec.GridSpec` replaces :class:`matplotlib.gridspec.GridSpec`
3232
# (see this `tutorial
3333
# <https://matplotlib.org/stable/tutorials/intermediate/gridspec.html>`__
3434
# for more on gridspecs).
3535
#
3636
# To make plots with these classes, you must start with the top-level commands
3737
# :func:`~ultraplot.ui.figure`, :func:`~ultraplot.ui.subplot`, or :func:`~ultraplot.ui.subplots`. These are
38-
# modeled after the :func:`~matplotlib.pyplot` commands of the same name. As in
39-
# :func:`~matplotlib.pyplot`, :func:`~ultraplot.ui.subplot` creates a figure and a single
38+
# modeled after the :mod:`~matplotlib.pyplot` commands of the same name. As in
39+
# :mod:`~matplotlib.pyplot`, :func:`~ultraplot.ui.subplot` creates a figure and a single
4040
# subplot, :func:`~ultraplot.ui.subplots` creates a figure and a grid of subplots, and
4141
# :func:`~ultraplot.ui.figure` creates an empty figure that can be subsequently filled
4242
# with subplots. A minimal example with just one subplot is shown below.
@@ -85,6 +85,7 @@
8585
# fig = uplt.figure(suptitle='Single subplot') # equivalent to above
8686
# ax = fig.subplot(xlabel='x axis', ylabel='y axis')
8787
ax.plot(data, lw=2)
88+
fig.show()
8889

8990

9091
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -95,11 +96,11 @@
9596
#
9697
# Similar to matplotlib, subplots can be added to figures one-by-one
9798
# or all at once. Each subplot will be an instance of
98-
# :class:`ultraplot.axes.Axes`. To add subplots all at once, use
99-
# :func:`ultraplot.figure.Figure.add_subplots` (or its shorthand,
100-
# :func:`ultraplot.figure.Figure.subplots`). Note that under the hood, the top-level
101-
# UltraPlot command :func:`~ultraplot.ui.subplots` simply calls :class::func:`~ultraplot.ui.figure`
102-
# followed by :func:`ultraplot.figure.Figure.add_subplots`.
99+
# :class:`~ultraplot.axes.Axes`. To add subplots all at once, use
100+
# :func:`~ultraplot.figure.Figure.add_subplots` (or its shorthand,
101+
# :func:`~ultraplot.figure.Figure.subplots`). Note that under the hood, the top-level
102+
# UltraPlot command :func:`~ultraplot.ui.subplots` simply calls :func:`~ultraplot.ui.figure`
103+
# followed by :func:`~ultraplot.figure.Figure.add_subplots`.
103104
#
104105
# * With no arguments, :func:`~ultraplot.figure.Figure.add_subplots` returns a subplot
105106
# generated from a 1-row, 1-column :class:`~ultraplot.gridspec.GridSpec`.
@@ -109,13 +110,13 @@
109110
# * With `array`, :func:`~ultraplot.figure.Figure.add_subplots` returns an arbitrarily
110111
# complex grid of subplots from a :class:`~ultraplot.gridspec.GridSpec` with matching
111112
# geometry. Here `array` is a 2D array representing a "picture" of the subplot
112-
# layout, where each unique integer indicates a `~matplotlib.gridspec.GridSpec`
113+
# layout, where each unique integer indicates a :class:`~matplotlib.gridspec.GridSpec`
113114
# slot occupied by the corresponding subplot and ``0`` indicates an empty space.
114115
# The returned subplots are contained in a :class:`~ultraplot.gridspec.SubplotGrid`
115116
# (:ref:`see below <ug_subplotgrid>` for details).
116117
#
117-
# To add subplots one-by-one, use the :func:`ultraplot.figure.Figure.add_subplot`
118-
# command (or its shorthand :func:`ultraplot.figure.Figure.subplot`).
118+
# To add subplots one-by-one, use the :func:`~ultraplot.figure.Figure.add_subplot`
119+
# command (or its shorthand :func:`~ultraplot.figure.Figure.subplot`).
119120
#
120121
# * With no arguments, :func:`~ultraplot.figure.Figure.add_subplot` returns a subplot
121122
# generated from a 1-row, 1-column :class:`~ultraplot.gridspec.GridSpec`.
@@ -124,7 +125,7 @@
124125
# as in matplotlib. Note that unlike matplotlib, the geometry must be compatible
125126
# with the geometry implied by previous :func:`~ultraplot.figure.Figure.add_subplot` calls.
126127
# * With a :class:`~matplotlib.gridspec.SubplotSpec` generated by indexing a
127-
# :class:`ultraplot.gridspec.GridSpec`, :func:`~ultraplot.figure.Figure.add_subplot` returns a
128+
# :class:`~ultraplot.gridspec.GridSpec`, :func:`~ultraplot.figure.Figure.add_subplot` returns a
128129
# subplot at the corresponding location. Note that unlike matplotlib, only
129130
# one :func:`~ultraplot.figure.Figure.gridspec` can be used with each figure.
130131
#
@@ -156,6 +157,7 @@
156157
fig.format(
157158
suptitle="Simple subplot grid", title="Title", xlabel="x axis", ylabel="y axis"
158159
)
160+
fig.show()
159161
# fig.save('~/example1.png') # save the figure
160162
# fig.savefig('~/example1.png') # alternative
161163

@@ -181,6 +183,7 @@
181183
ylabel="ylabel",
182184
)
183185
axs[2].plot(data, lw=2)
186+
fig.show()
184187
# fig.save('~/example2.png') # save the figure
185188
# fig.savefig('~/example2.png') # alternative
186189

@@ -203,6 +206,7 @@
203206
suptitle="Really complex subplot grid", xlabel="xlabel", ylabel="ylabel", abc=True
204207
)
205208
axs[0].plot(data, lw=2)
209+
fig.show()
206210
# fig.save('~/example3.png') # save the figure
207211
# fig.savefig('~/example3.png') # alternative
208212

@@ -222,6 +226,7 @@
222226
fig.format(
223227
suptitle="Subplot grid with a GridSpec", xlabel="xlabel", ylabel="ylabel", abc=True
224228
)
229+
fig.show()
225230
# fig.save('~/example4.png') # save the figure
226231
# fig.savefig('~/example4.png') # alternative
227232

@@ -234,7 +239,7 @@
234239
# If you create subplots all-at-once with e.g. :func:`~ultraplot.ui.subplots`,
235240
# UltraPlot returns a :class:`~ultraplot.gridspec.SubplotGrid` of subplots. This list-like,
236241
# array-like object provides some useful features and unifies the behavior of the
237-
# three possible return types used by `matplotlib.pyplot.subplots`:
242+
# three possible return types used by :func:`matplotlib.pyplot.subplots`:
238243
#
239244
# * :class:`~ultraplot.gridspec.SubplotGrid` behaves like a scalar when it is singleton.
240245
# In other words, if you make a single subplot with ``fig, axs = uplt.subplots()``,
@@ -255,7 +260,7 @@
255260
# :func:`~ultraplot.gridspec.SubplotGrid.panel_axes`,
256261
# :func:`~ultraplot.gridspec.SubplotGrid.inset_axes`,
257262
# :func:`~ultraplot.gridspec.SubplotGrid.altx`, and :func:`~ultraplot.gridspec.SubplotGrid.alty`.
258-
# In the below example, we use `ultraplot.gridspec.SubplotGrid.format` on the grid
263+
# In the below example, we use :func:`~ultraplot.gridspec.SubplotGrid.format` on the grid
259264
# returned by :func:`~ultraplot.ui.subplots` to format different subgroups of subplots
260265
# (:ref:`see below <ug_format>` for more on the format command).
261266
#
@@ -264,7 +269,7 @@
264269
# If you create subplots one-by-one with :func:`~ultraplot.figure.Figure.subplot` or
265270
# :func:`~ultraplot.figure.Figure.add_subplot`, a :class:`~ultraplot.gridspec.SubplotGrid`
266271
# containing the numbered subplots is available via the
267-
# :class:`ultraplot.figure.Figure.subplotgrid` property. As with subplots made
272+
# :class:`~ultraplot.figure.Figure.subplotgrid` property. As with subplots made
268273
# all-at-once, the subplots in the grid are sorted by :func:`~ultraplot.axes.Axes.number`.
269274

270275
# %%
@@ -294,6 +299,7 @@
294299
axs[1, :1].format(fc="sky blue")
295300
axs[-1, -1].format(fc="gray4", grid=False)
296301
axs[0].plot((state.rand(50, 10) - 0.5).cumsum(axis=0), cycle="Grays_r", lw=2)
302+
fig.show()
297303

298304

299305
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -305,13 +311,13 @@
305311
# Matplotlib includes `two different interfaces
306312
# <https://matplotlib.org/stable/api/index.html>`__ for plotting stuff:
307313
# a python-style object-oriented interface with axes-level commands
308-
# like :func:`matplotlib.axes.Axes.plot`, and a MATLAB-style :func:`~matplotlib.pyplot` interface
314+
# like :method:`matplotlib.axes.Axes.plot`, and a MATLAB-style :mod:`~matplotlib.pyplot` interface
309315
# with global commands like :func:`matplotlib.pyplot.plot` that track the "current" axes.
310-
# UltraPlot builds upon the python-style interface using the `ultraplot.axes.PlotAxes`
316+
# UltraPlot builds upon the python-style interface using the `~ultraplot.axes.PlotAxes`
311317
# class. Since every axes used by UltraPlot is a child of :class:`~ultraplot.axes.PlotAxes`, we
312318
# are able to add features directly to the axes-level commands rather than relying
313319
# on a separate library of commands (note that while some of these features may be
314-
# accessible via :func:`~matplotlib.pyplot` commands, this is not officially supported).
320+
# accessible via :mod:`~matplotlib.pyplot` commands, this is not officially supported).
315321
#
316322
# For the most part, the features added by :class:`~ultraplot.axes.PlotAxes` represent
317323
# a *superset* of matplotlib. If you are not interested, you can use the plotting
@@ -353,6 +359,7 @@
353359
suptitle="Quick plotting demo",
354360
)
355361
fig.colorbar(m, loc="b", label="label")
362+
fig.show()
356363

357364

358365
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -364,9 +371,9 @@
364371
# Matplotlib includes `two different interfaces
365372
# <https://matplotlib.org/stable/api/index.html>`__ for formatting stuff:
366373
# a "python-style" object-oriented interface with instance-level commands
367-
# like `matplotlib.axes.Axes.set_title`, and a "MATLAB-style" interface
374+
# like :func:`matplotlib.axes.Axes.set_title`, and a "MATLAB-style" interface
368375
# that tracks current axes and provides global commands like
369-
# `matplotlib.pyplot.title`.
376+
# :func:`matplotlib.pyplot.title`.
370377
#
371378
# UltraPlot provides the ``format`` command as an
372379
# alternative "python-style" command for formatting a variety of plot elements.
@@ -380,28 +387,28 @@
380387
#
381388
# * Figure settings. These are related to row labels, column labels, and
382389
# figure "super" titles -- for example, ``fig.format(suptitle='Super title')``.
383-
# See `ultraplot.figure.Figure.format` for details.
390+
# See :func:`~ultraplot.figure.Figure.format` for details.
384391
#
385392
# * General axes settings. These are related to background patches,
386393
# a-b-c labels, and axes titles -- for example, ``ax.format(title='Title')``
387-
# See `ultraplot.axes.Axes.format` for details.
394+
# See :func:`~ultraplot.axes.Axes.format` for details.
388395
#
389-
# * Cartesian axes settings (valid only for `~ultraplot.axes.CartesianAxes`).
396+
# * Cartesian axes settings (valid only for :class:`~ultraplot.axes.CartesianAxes`).
390397
# These are related to *x* and *y* axis ticks, spines, bounds, and labels --
391398
# for example, ``ax.format(xlim=(0, 5))`` changes the x axis bounds.
392-
# See :func:`ultraplot.axes.CartesianAxes.format` and
399+
# See :func:`~ultraplot.axes.CartesianAxes.format` and
393400
# :ref:`this section <ug_cartesian>` for details.
394401
#
395402
# * Polar axes settings (valid only for :class:`~ultraplot.axes.PolarAxes`).
396403
# These are related to azimuthal and radial grid lines, bounds, and labels --
397404
# for example, ``ax.format(rlim=(0, 10))`` changes the radial bounds.
398-
# See `ultraplot.axes.PolarAxes.format`
405+
# See :func:`~ultraplot.axes.PolarAxes.format`
399406
# and :ref:`this section <ug_polar>` for details.
400407
#
401-
# * Geographic axes settings (valid only for `~ultraplot.axes.GeoAxes`).
408+
# * Geographic axes settings (valid only for :class:`~ultraplot.axes.GeoAxes`).
402409
# These are related to map bounds, meridian and parallel lines and labels,
403410
# and geographic features -- for example, ``ax.format(latlim=(0, 90))``
404-
# changes the meridional bounds. See `ultraplot.axes.GeoAxes.format`
411+
# changes the meridional bounds. See :func:`~ultraplot.axes.GeoAxes.format`
405412
# and :ref:`this section <ug_geoformat>` for details.
406413
#
407414
# * :func:`~ultraplot.config.rc` settings. Any keyword matching the name
@@ -414,10 +421,10 @@
414421
# See :ref:`this section <ug_config>` for more on rc settings.
415422
#
416423
# A ``format`` command is available on every figure and axes.
417-
# `ultraplot.figure.Figure.format` accepts both figure and axes
424+
# :func:`~ultraplot.figure.Figure.format` accepts both figure and axes
418425
# settings (applying them to each numbered subplot by default).
419-
# Similarly, `ultraplot.axes.Axes.format` accepts both axes and figure
420-
# settings. There is also a `ultraplot.gridspec.SubplotGrid.format`
426+
# Similarly, :func:`~ultraplot.axes.Axes.format` accepts both axes and figure
427+
# settings. There is also a :func:`~ultraplot.gridspec.SubplotGrid.format`
421428
# command that can be used to change settings for a subset of
422429
# subplots -- for example, ``axs[:2].format(xtickminor=True)``
423430
# turns on minor ticks for the first two subplots (see
@@ -463,6 +470,7 @@
463470
xtickminor=False,
464471
ygridminor=True,
465472
)
473+
fig.show()
466474

467475
# %% [raw] raw_mimetype="text/restructuredtext"
468476
# .. _ug_rc:
@@ -471,19 +479,19 @@
471479
# -------------------
472480
#
473481
# A dictionary-like object named :func:`~ultraplot.config.rc` is created when you import
474-
# UltraPlot. :func:`~ultraplot.config.rc` is similar to the matplotlib `~matplotlib.rcParams`
482+
# UltraPlot. :func:`~ultraplot.config.rc` is similar to the matplotlib :data:`~matplotlib.rcParams`
475483
# dictionary, but can be used to change both `matplotlib settings
476484
# <https://matplotlib.org/stable/tutorials/introductory/customizing.html>`__ and
477485
# :ref:`ultraplot settings <ug_rcUltraPlot>`. The matplotlib-specific settings are
478-
# stored in :func:`~ultraplot.config.rc_matplotlib` (our name for `matplotlib.rcParams`) and
479-
# the UltraPlot-specific settings are stored in `~ultraplot.config.rc_UltraPlot`.
486+
# stored in :func:`~ultraplot.config.rc_matplotlib` (our name for :data:`~matplotlib.rcParams`) and
487+
# the UltraPlot-specific settings are stored in :class:`~ultraplot.config.rc_ultraplot`.
480488
# UltraPlot also includes a :rcraw:`style` setting that can be used to
481489
# switch between `matplotlib stylesheets
482490
# <https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html>`__.
483491
# See the :ref:`configuration section <ug_config>` for details.
484492
#
485493
# To modify a setting for just one subplot or figure, you can pass it to
486-
# `ultraplot.axes.Axes.format` or `ultraplot.figure.Figure.format`. To temporarily
494+
# :func:`~ultraplot.axes.Axes.format` or :func:`~ultraplot.figure.Figure.format`. To temporarily
487495
# modify setting(s) for a block of code, use :func:`~ultraplot.config.Configurator.context`.
488496
# To modify setting(s) for the entire python session, just assign it to the
489497
# :func:`~ultraplot.config.rc` dictionary or use :func:`~ultraplot.config.Configurator.update`.
@@ -530,6 +538,7 @@
530538
titleloc="r",
531539
titlecolor="gray7",
532540
)
541+
fig.show()
533542

534543
# Reset persistent modifications from head of cell
535544
uplt.rc.reset()
@@ -554,3 +563,4 @@
554563
for ax, style in zip(axs, styles):
555564
ax.format(style=style, xlabel="xlabel", ylabel="ylabel", title=style)
556565
ax.plot(data, linewidth=3)
566+
fig.show()

0 commit comments

Comments
 (0)