Skip to content

Commit 246ffde

Browse files
committed
More docs cleanup
1 parent 5198062 commit 246ffde

9 files changed

Lines changed: 110 additions & 109 deletions

File tree

docs/2dplots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
('fair', 'unfair')
199199
):
200200
for fair in ('fair', 'unfair'):
201-
norm = plot.Norm('diverging', unfair=(fair == 'unfair'))
201+
norm = plot.Norm('diverging', fair=(fair == 'fair'))
202202
ax = axs[i]
203203
m = ax.contourf(data, cmap=cmap, norm=norm)
204204
ax.colorbar(m, loc='b', locator=1)

docs/colormaps.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
# %%
7474
import proplot as plot
75-
fig = plot.show_cmaps()
75+
fig, axs = plot.show_cmaps()
7676

7777

7878
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -118,10 +118,10 @@
118118

119119
# %%
120120
import proplot as plot
121-
fig = plot.show_colorspaces(axwidth=1.6, luminance=50)
122-
fig = plot.show_colorspaces(axwidth=1.6, saturation=60)
123-
fig = plot.show_colorspaces(axwidth=1.6, hue=0)
124-
fig = plot.show_channels(
121+
fig, axs = plot.show_colorspaces(axwidth=1.6, luminance=50)
122+
fig, axs = plot.show_colorspaces(axwidth=1.6, saturation=60)
123+
fig, axs = plot.show_colorspaces(axwidth=1.6, hue=0)
124+
fig, axs = plot.show_channels(
125125
'magma', 'rocket', 'fire', 'dusk',
126126
axwidth=1.4, minhue=-180, maxsat=300, rgb=False
127127
)
@@ -216,8 +216,8 @@
216216
axs[4].format(title='From list of colors')
217217

218218
# Test the channels
219-
fig = plot.show_channels(cmap1, cmap2, axwidth=1.4, rgb=False)
220-
fig = plot.show_channels(
219+
fig, axs = plot.show_channels(cmap1, cmap2, axwidth=1.4, rgb=False)
220+
fig, axs = plot.show_channels(
221221
cmap3, cmap4, cmap5, minhue=-180,
222222
axwidth=1.4, rgb=False
223223
)

docs/colors.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030
#
3131
# ProPlot adds new color names from the `XKCD color survey
3232
# <https://blog.xkcd.com/2010/05/03/color-survey-results/>`__ and
33-
# the `"Open color" <https://github.com/yeun/open-color>`__ Github project.
34-
# This was inspired by `seaborn
35-
# <https://seaborn.pydata.org/tutorial/color_palettes.html>`__. Use
36-
# `~proplot.show.show_colors` to generate tables of these colors. Note that
37-
# the matplotlib's native `X11 named colors
33+
# the `Open Color <https://github.com/yeun/open-color>`__ UI design color
34+
# palettes. You can use `~proplot.show.show_colors` to generate a table of these
35+
# colors. Note that the matplotlib's native `X11 named colors
3836
# <https://matplotlib.org/examples/color/named_colors.html>`__ are still
39-
# registered, but we encourage using colors from the tables instead, and
40-
# some of the X11 color names may be overwritten by the XKCD names. We prefer
41-
# the XKCD color names because the selection is larger and the names are
37+
# registered, but some of the X11 color names may be overwritten by the XKCD names,
38+
# and we encourage choosing colors from the below tables instead. ProPlot
39+
# registers XKCD colors because the selection is larger and the names are
4240
# more likely to match your intuition for what a color "should" look like.
4341
#
4442
# To reduce the number of registered color names to a more manageable size,
@@ -50,7 +48,7 @@
5048

5149
# %%
5250
import proplot as plot
53-
figs = plot.show_colors()
51+
fig, axs = plot.show_colors()
5452

5553

5654
# %% [raw] raw_mimetype="text/restructuredtext"

docs/cycles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# %%
4848
import proplot as plot
49-
fig = plot.show_cycles()
49+
fig, axs = plot.show_cycles()
5050

5151

5252
# %% [raw] raw_mimetype="text/restructuredtext"

docs/environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ dependencies:
1919
- pip:
2020
- ..
2121
- pyqt5
22-
- jupytext
23-
- nbsphinx
22+
- sphinx>=3.0
2423
- sphinx-copybutton
2524
- sphinx_rtd_theme
25+
- jupytext
26+
- nbsphinx
2627
- git+https://github.com/lukelbd/sphinx-automodapi@v0.8.proplot-mods

docs/fonts.py

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Font selection
1919
# ==============
2020
#
21-
# ProPlot registers several new font families and includes tools for adding
21+
# ProPlot registers several new fonts and includes tools for adding
2222
# your own fonts. These features are described below.
2323
#
2424
#
@@ -38,13 +38,12 @@
3838
# is `DejaVu Sans <https://dejavu-fonts.github.io>`__, which comes packaged with
3939
# matplotlib.
4040
#
41-
# Matplotlib uses DejaVu Sans in part because it includes glyphs
42-
# for a wider range of mathematical symbols. However in your opinion, DejaVu Sans
43-
# not very aesthetically pleasing or particularly readable, and it is
44-
# seldom used outside of the matplotlib ecosystem.
45-
# To improve the font selection and make things consistent across different
46-
# workspaces, ProPlot comes packaged with the open-source
47-
# `TeX Gyre <http://www.gust.org.pl/projects/e-foundry/tex-gyre>`__ font series
41+
# Matplotlib uses DejaVu Sans in part because it includes glyphs for a very wide
42+
# range of symbols, especially mathematical symbols. However DejaVu Sans is seldom
43+
# used outside of matplotlib and (in our opinion) is not very aesthetically pleasing.
44+
# To improve the font selection while keeping things consistent across different
45+
# workstations, ProPlot comes packaged with the open-source
46+
# `TeX Gyre font series <https://ctan.org/pkg/tex-gyre?lang=en>`__
4847
# and adds them as the default entries for all of matplotlib's font famlies:
4948
#
5049
# * The `Century <https://en.wikipedia.org/wiki/Century_type_family>`__ lookalike
@@ -58,27 +57,26 @@
5857
# * The `Avant Garde <https://en.wikipedia.org/wiki/ITC_Avant_Garde>`__ lookalike
5958
# :rcraw:`font.fantasy` = ``'TeX Gyre Adventor'``.
6059
#
61-
# Thus after importing ProPlot, even on sparse Linux servers with limited font
62-
# selection, the default font will be a more conventional and aesthetically
63-
# pleasing Helvetica lookalike. The new font priority lists for each font family
64-
# are shown in the :ref:`default proplotrc file <ug_proplotrc>`.
60+
# Thus after importing ProPlot, the default font will be the more conventional
61+
# and aesthetically pleasing Helvetica lookalike
62+
# `TeX Gyre Heros <https://ctan.org/pkg/tex-gyre-heros>`__. The new font priority
63+
# lists for each font family are shown in the
64+
# :ref:`default proplotrc file <ug_proplotrc>`.
6565
#
6666
# To compare different fonts, use the `~proplot.show.show_fonts` command. By
67-
# default, this displays the *sans-serif* fonts available on your system and
68-
# included with ProPlot. The default table on a sparse Linux server is shown
67+
# default, this displays the *sans serif* fonts available on your system and
68+
# packaged with ProPlot. The default table on a sparse Linux server is shown
6969
# below. The "¤" symbol appears where characters for a particular font are
70-
# unavailable. When you are actually making plots, "¤" will be filled with
71-
# the character from a fallback font.
72-
#
73-
# It should be noted that most of the TeX Gyre fonts have limited character
74-
# availability. If your plots contain lots of mathematical symbols,
75-
# you may want to switch the default :rcraw:`font.family` to DejaVu Sans, which
76-
# is packaged with matplotlib, or `Fira Math <https://github.com/firamath/firamath>`__,
77-
# which is also packaged with ProPlot.
70+
# unavailable (when making plots, "¤" is replaced with the character from
71+
# a fallback font). Since most TeX Gyre fonts have limited
72+
# character sets, if your plots contain lots of mathematical symbols,
73+
# you may want to set :rcraw:`font.family` to DejaVu Sans or
74+
# `Fira Math <https://github.com/firamath/firamath>`__, which is packaged
75+
# with ProPlot.
7876

7977
# %%
8078
import proplot as plot
81-
fig = plot.show_fonts()
79+
fig, axs = plot.show_fonts()
8280

8381

8482
# %% [raw] raw_mimetype="text/restructuredtext"
@@ -94,14 +92,13 @@
9492
# the :ref:`configuration section <ug_config>` for details.
9593
#
9694
# Sometimes the font you would like to use *is* installed, but the font file
97-
# is not stored under the matplotlib-compatible ``.ttf``, ``.otf``, or
98-
# ``.afm`` formats. For example, several macOS fonts are unavailable because
99-
# they are stored as ``.dfont`` collections. Also, while matplotlib nominally
100-
# supports ``.ttc`` collections, ProPlot manually removes them because
101-
# figures with ``.ttc`` fonts
95+
# is not stored under the matplotlib-compatible ``.ttf``, ``.otf``, or ``.afm``
96+
# formats. For example, several macOS fonts are unavailable because they are
97+
# stored as ``.dfont`` collections. Also, while matplotlib nominally supports
98+
# ``.ttc`` collections, ProPlot ignores them because figures with ``.ttc`` fonts
10299
# `cannot be saved as PDFs <https://github.com/matplotlib/matplotlib/issues/3135>`__.
103-
# You can get matplotlib to use these fonts by expanding the "collections"
104-
# into individual ``.ttf`` files with the
100+
# You can get matplotlib to use ``.dfont`` and ``.ttc`` collections by
101+
# expanding them into individual ``.ttf`` files with the
105102
# `DFontSplitter application <https://peter.upfold.org.uk/projects/dfontsplitter>`__,
106103
# then saving the files in-place or in the ``~/.proplot/fonts`` folder.
107104
#

docs/insets_panels.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232
# to the `~proplot.axes.Axes.panel` or `~proplot.axes.Axes.panel_axes` methods.
3333
# The resulting axes are instances of `~proplot.axes.CartesianAxes`.
3434
#
35-
# To generate "stacked" panels, simply call `~proplot.axes.Axes.panel` or
36-
# `~proplot.axes.Axes.panel_axes` more than once. To include panels when
37-
# centering spanning axis labels and super titles, pass
38-
# ``includepanels=True`` to `~proplot.figure.Figure`. Panels
35+
# To generate "stacked" panels, simply call `~proplot.axes.Axes.panel` more
36+
# than once. To include panels when centering spanning axis labels and super
37+
# titles, pass ``includepanels=True`` to `~proplot.figure.Figure`. Panels
3938
# :ref:`do not interfere with the tight layout algorithm <ug_tight>` and
4039
# :ref:`do not affect the subplot aspect ratios <ug_autosize>`.
4140
#
@@ -95,7 +94,7 @@
9594

9695
# Panels do not interfere with subplot layout
9796
for ax, side in zip(axs, 'tlbr'):
98-
ax.panel_axes(side, width='3em')
97+
ax.panel(side, width='3em')
9998
axs.format(
10099
title='Title', suptitle='Complex arrangement of panels',
101100
collabels=['Column 1', 'Column 2'],

docs/subplots.py

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
#
5454
# This algorithm also has the following notable properties:
5555
#
56-
# * For very simple subplot grids (e.g. ``plot.subplots(ncols=2, nrows=3)``),
57-
# `aspect`, `axwidth`, and `axheight` apply to every subplot in the figure --
58-
# not just the reference subplot.
56+
# * For very simple subplot grids (i.e. subplots created with the `ncols` and
57+
# `nrows` arguments), the arguments `aspect`, `axwidth`, and `axheight` apply
58+
# to every subplot in the figure -- not just the reference subplot.
5959
# * When the reference subplot `aspect ratio\
6060
# <https://matplotlib.org/2.0.2/examples/pylab_examples/equal_aspect_ratio.html>`__
6161
# has been manually overridden (e.g. with ``ax.set_aspect(1)``) or is set
@@ -144,27 +144,27 @@
144144
# Automatic subplot spacing
145145
# -------------------------
146146
#
147-
# By default, ProPlot applies a *tight layout* algorithm to every figure.
148-
# This algorithm automatically adjusts the space between subplot rows and
149-
# columns and the figure edge to accomadate labels. It can be disabled by
150-
# passing ``tight=False`` to `~proplot.ui.subplots`.
151-
#
147+
# In addition to automatic figure sizing, by default ProPlot applies a *tight layout*
148+
# algorithm to every figure. This algorithm automatically adjusts the space between
149+
# subplot rows and columns and the figure edge to accommodate labels.
150+
# It can be disabled by passing ``tight=False`` to `~proplot.ui.subplots`.
152151
# While matplotlib has `its own tight layout algorithm
153152
# <https://matplotlib.org/3.1.1/tutorials/intermediate/tight_layout_guide.html>`__,
154-
# ProPlot's algorithm permits variable spacing between subsequent subplot
155-
# rows and columns (see the new `~proplot.gridspec.GridSpec` class) and may
156-
# change the figure size (depending on the keyword arguments passed to
157-
# `~proplot.ui.subplots`).
153+
# ProPlot's algorithm may change the figure size to accommodate the correct spacing
154+
# and permits variable spacing between subsequent subplot rows and columns (see the
155+
# new `~proplot.gridspec.GridSpec` class for details).
158156
#
159-
# ProPlot's tight layout algorithm can also be easily overridden. When you
157+
# The tight layout algorithm can also be easily overridden. When you
160158
# pass a spacing argument like `left`, `right`, `top`, `bottom`, `wspace`, or
161-
# `hspace` to `~proplot.ui.subplots`, that value is always respected:
159+
# `hspace` to `~proplot.ui.subplots`, that value is always respected. For example:
162160
#
163-
# * With ``left='2em'``, the left margin is fixed but the right, bottom, and
164-
# top margins are calculated automatically.
165-
# * With ``wspace=('3em', None)`` (and ``ncols=3``), the space between the
166-
# first two columns is fixed, while the space between the second two columns
167-
# is calculated automatically.
161+
# * ``left='2em'`` fixes the left margin, while the right, bottom, and
162+
# top margins are determined automatically.
163+
# * ``wspace='1em'`` fixes the spaces between subplot columns, while the spaces
164+
# between subplot rows are determined automatically.
165+
# * ``wspace=('3em', None)`` fixes the space between the first two columns of
166+
# a three-column plot, while the space between the second two columns is
167+
# determined automatically.
168168
#
169169
# The below examples demonstrate how the tight layout algorithm permits
170170
# variable spacing between subplot rows and columns.
@@ -201,7 +201,7 @@
201201

202202
# Formatting that stress-tests the algorithm
203203
axs.format(
204-
xlim=(-1.2, 1.2), ylim=(-1.2, 1.2), xlocator=1, ylocator=1,
204+
xlim=(-1.5, 1.5), ylim=(-1.5, 1.5), xlocator=1, ylocator=1,
205205
suptitle='Tight layout with user overrides',
206206
rowlabels=['Row 1', 'Row 2', 'Row 3'],
207207
collabels=['Column 1', 'Column 2', 'Column 3', 'Column 4']
@@ -245,27 +245,29 @@
245245
wspace=('10pt', '20pt'), right='10mm'
246246
)
247247
panel = axs[2].panel_axes('r', width='2em')
248+
panel.format(xlim=(0, 1))
248249
axs.format(
249250
suptitle='Arguments with arbitrary units',
250-
xlabel='x axis', ylabel='y axis'
251+
xlabel='x axis', ylabel='y axis',
252+
xlim=(0, 1), ylim=(0, 1),
251253
)
252254

253255

254256
# %% [raw] raw_mimetype="text/restructuredtext"
255257
# .. _ug_abc:
256258
#
257-
# Subplot a-b-c labels
259+
# A-b-c subplot labels
258260
# --------------------
259261
#
260262
# ProPlot can be used to add "a-b-c" labels to subplots. This is possible
261-
# because `~proplot.ui.subplots` assigns unique
262-
# `~proplot.axes.Axes.number`\ s to each subplot. If you passed an `array` to
263+
# because `~proplot.ui.subplots` assigns unique `~proplot.axes.Axes.number`\ s
264+
# to each subplot. If you :ref:`passed an array <ug_intro>` to
263265
# `~proplot.ui.subplots`, the subplot numbers correspond to the numbers in
264-
# the array. Otherwise, if you used the `ncols` and `nrows` keyword
265-
# arguments, the number order is row-major by default but can be switched to
266-
# column-major by passing ``order='C'`` to `~proplot.ui.subplots`. The number
267-
# order also determines the subplot order in the
268-
# `~proplot.ui.SubplotsContainer` returned by `~proplot.ui.subplots`.
266+
# the array. If you used the `ncols` and `nrows` keyword arguments, the number
267+
# order is row-major by default but can be switched to column-major by passing
268+
# ``order='C'`` to `~proplot.ui.subplots`. The number order also determines the
269+
# subplot order in the `~proplot.ui.SubplotsContainer` returned by
270+
# `~proplot.ui.subplots`.
269271
#
270272
# To turn on "a-b-c" labels, set :rcraw:`abc` to ``True`` or pass
271273
# ``abc=True`` to `~proplot.axes.Axes.format` (see
@@ -287,29 +289,33 @@
287289
# %% [raw] raw_mimetype="text/restructuredtext"
288290
# .. _ug_share:
289291
#
290-
# Shared and spanning labels
291-
# --------------------------
292-
#
293-
# Matplotlib has an "axis sharing" feature that holds axis limits the same
294-
# for axes within a grid of subplots. But this has no effect on the axis
295-
# labels and tick labels, which can lead to lots of redundancies.
292+
# Axis sharing
293+
# ------------
296294
#
297-
# To help you eliminate these redundancies, ProPlot introduces four
298-
# axis-sharing options and a new spanning label option, controlled by the
299-
# `share`, `sharex`, `sharey`, `span`, `spanx`, and `spany`
300-
# `~proplot.ui.subplots` keyword args.
295+
# Redundant labels are a common problem for figures with lots of subplots. To
296+
# address this, `matplotlib.pyplot.subplots` includes `sharex` and `sharey`
297+
# keywords that permit sharing axis limits, ticks, and tick labels between like
298+
# rows and columns of subplots. However there is no convenient way to enable
299+
# axis sharing between complex grids of subplots, nor is there a way to share axis
300+
# labels between subplots in the same row or column.
301301
#
302-
# #. Level ``1`` hides inner *x* and *y* axis labels.
303-
# #. Level ``2`` is the same as ``1``, but the *x* and *y* axis limits are locked.
304-
# #. Level ``3`` is the same as ``2``, but the *x* and *y* tick labels are hidden.
302+
# ProPlot expands upon this feature by introducing a new option for drawing
303+
# labels that "span" subplots in the same row or column, controlled by the
304+
# `spanx` and `spany` keywords, along with four axis-sharing "levels"
305+
# rather than just one, controlled with the `sharex` and `sharey` keywords:
305306
#
306-
# "Spanning labels" are centered *x* and *y* axis labels used for subplots
307-
# whose spines are on the same row or column. See the below example.
307+
# * Level ``0`` disables axis sharing.
308+
# * Level ``1`` shares duplicate *x* and *y* axis labels, but nothing else.
309+
# * Level ``2`` is the same as ``1``, but the *x* and *y* axis limits, ticks,
310+
# and scales are also shared.
311+
# * Level ``3`` is the same as ``2``, but the *x* and *y* tick labels are
312+
# also shared.
308313
#
309-
# Note that the the "shared" and "spanning" axes are determined automatically
310-
# based on the extent of each subplot in the `~proplot.gridspec.GridSpec`.
311-
# Since ProPlot uses just one `~proplot.gridspec.GridSpec` per figure, this
312-
# can be done with zero ambiguity.
314+
# These features are best illustrated by example (see below). Note that since
315+
# "shared" and "spanning" labels are determined automatically based on position of
316+
# each subplot in the `~proplot.gridspec.GridSpec`, these features work for
317+
# arbitrarily complex figures. Since ProPlot uses just one `~proplot.gridspec.GridSpec`
318+
# per figure, this can be done with zero ambiguity.
313319

314320
# %%
315321
import proplot as plot
@@ -326,14 +332,14 @@
326332
# Same plot with different sharing and spanning settings
327333
for share in (0, 1, 2, 3):
328334
fig, axs = plot.subplots(
329-
ncols=4, aspect=1, axwidth=1.2,
335+
ncols=4, aspect=1, axwidth=1.06,
330336
sharey=share, spanx=share // 2
331337
)
332338
for ax, data in zip(axs, datas):
333339
on = ['off', 'on'][share // 2]
334340
ax.plot(data, cycle=colors)
335341
ax.format(
336-
suptitle=f'Axis-sharing level: {share}, spanning labels {on}',
342+
suptitle=f'Sharing level {share}, spanning labels {on}',
337343
grid=False, xlabel='spanning', ylabel='shared'
338344
)
339345

0 commit comments

Comments
 (0)