Skip to content

Commit 0753a40

Browse files
committed
Update docs, fix ore gridspec docs bugs
1 parent df2125c commit 0753a40

File tree

4 files changed

+68
-62
lines changed

4 files changed

+68
-62
lines changed

docs/1dplots.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,16 @@
182182
# <https://matplotlib.org/tutorials/intermediate/color_cycle.html#sphx-glr-tutorials-intermediate-color-cycle-py>`__
183183
# and use different property cycles for different plot elements. You can create and
184184
# apply property cycles on-the-fly using the `cycle` and `cycle_kw` keywords, available
185-
# with most 1D plotting commands. `cycle` and `cycle_kw` are passed to the
186-
# `~proplot.constructor.Cycle` :ref:`constructor function <why_constructor>`, and the
187-
# resulting property cycle is used for the plot. You can specify `cycle` once with
188-
# 2D input data (in which case each column is plotted in succession according to
189-
# the property cycle) or call a plotting command multiple times with the same
190-
# `cycle` argument each time (the property cycle is not reset). You can also
191-
# disable property cycling with ``cycle=False``, ``cycle='none'``, or ``cycle=()``
192-
# and re-enable the default property cycle with ``cycle=True``. For more information
193-
# on property cycling, see the :ref:`color cycles section <ug_cycles>` and
194-
# `this matplotlib tutorial
185+
# with most `~proplot.axes.PlotAxes` 1D plotting commands. `cycle` and `cycle_kw` are
186+
# passed to the `~proplot.constructor.Cycle` :ref:`constructor function
187+
# <why_constructor>`, and the resulting property cycle is used for the plot. You
188+
# can specify `cycle` once with 2D input data (in which case each column is
189+
# plotted in succession according to the property cycle) or call a plotting
190+
# command multiple times with the same `cycle` argument each time (the property
191+
# cycle is not reset). You can also disable property cycling with
192+
# ``cycle=False``, ``cycle='none'``, or ``cycle=()`` and re-enable the default
193+
# property cycle with ``cycle=True``. For more information on property cycling,
194+
# see the :ref:`color cycles section <ug_cycles>` and `this matplotlib tutorial
195195
# <https://matplotlib.org/tutorials/intermediate/color_cycle.html#sphx-glr-tutorials-intermediate-color-cycle-py>`__.
196196

197197
# %%
@@ -490,16 +490,17 @@
490490
# `~proplot.axes.PlotAxes.scatterx`. `~proplot.axes.PlotAxes.bar`, and
491491
# `~proplot.axes.PlotAxes.barh` plots using any of several keyword arguments.
492492
#
493-
# If you pass 2D arrays to these commands with ``mean=True`` or ``median=True``,
494-
# the means or medians of each column are drawn as lines, points, or bars, while
495-
# *error bars* or *error shading* indicates the spread of the distribution
496-
# for each column. Invalid data is ignored. You can also specify the error bounds
497-
# *manually* with the `bardata`, `boxdata`, `shadedata`, and `fadedata` keywords.
498-
# These commands can draw and style thin error bars (the ``bar`` keywords), thick
499-
# "boxes" overlaid on top of these bars (the ``box`` keywords; think of them as
500-
# miniature boxplots), a transparent shading region (the ``shade`` keywords), and
501-
# a more transparent secondary shading region (the ``fade`` keywords). See the
502-
# documentation on the plotting commands for details.
493+
# If you pass 2D arrays to these commands with ``mean=True``, ``means=True``,
494+
# ``median=True``, or ``medians=True``, the means or medians of each column are
495+
# drawn as lines, points, or bars, while *error bars* or *error shading*
496+
# indicates the spread of the distribution in each column. Invalid data is
497+
# ignored. You can also specify the error bounds *manually* with the `bardata`,
498+
# `boxdata`, `shadedata`, and `fadedata` keywords. These commands can draw and
499+
# style thin error bars (the ``bar`` keywords), thick "boxes" overlaid on top of
500+
# these bars (the ``box`` keywords; think of them as miniature boxplots), a
501+
# transparent primary shading region (the ``shade`` keywords), and a more
502+
# transparent secondary shading region (the ``fade`` keywords). See the documentation
503+
# on the plotting commands for details.
503504

504505

505506
# %%
@@ -704,14 +705,14 @@
704705
# Parametric plots
705706
# ----------------
706707
#
707-
# To make "parametric" plots, use the new `~proplot.axes.PlotAxes.parametric`
708-
# command. Parametric plots are `~matplotlib.collections.LineCollection`\ s that
709-
# map individual line segments to individual colors, where each segment represents a
708+
# Parametric plots can be drawn using the new `~proplot.axes.PlotAxes.parametric`
709+
# command. This creates `~matplotlib.collections.LineCollection`\ s that map
710+
# individual line segments to individual colors, where each segment represents a
710711
# "parametric" coordinate (e.g., time). The parametric coordinates are specified with
711-
# the `values` keyword argument. See `~proplot.axes.PlotAxes.parametric` for details.
712-
# As shown below, it is also easy to build colorbars from the
713-
# `~matplotlib.collections.LineCollection` returned by
714-
# `~proplot.axes.PlotAxes.parametric`.
712+
# a third positional argument or with the keywords `c`, `color`, `colors` or `values`.
713+
# Representing parametric coordinates with colors instead of text labels can be
714+
# cleaner. The below example makes a simple `~proplot.axes.PlotAxes.parametric`
715+
# plot with a colorbar indicating the parametric coordinate.
715716

716717
# %%
717718
import proplot as pplt

docs/2dplots.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,19 @@
183183
# It is often useful to create `~proplot.colors.ContinuousColormap`\ s
184184
# on-the-fly, without explicitly calling the `~proplot.constructor.Colormap`
185185
# :ref:`constructor function <why_constructor>`. You can do so using the `cmap`
186-
# and `cmap_kw` keywords. For example, to create and apply a monochromatic
187-
# colormap, you can use ``cmap='color_name'`` (see the :ref:`colormaps section
188-
# <ug_cmaps>` for more info). You can also create on-the-fly "qualitative"
189-
# `~proplot.colors.DiscreteColormap`\ s by passing lists of colors to
190-
# the keyword `c`, `color`, or `colors`.
186+
# and `cmap_kw` keywords, available with most `~proplot.axes.PlotAxes` 2d plotting
187+
# commands. For example, to create and apply a monochromatic colormap, you can use
188+
# ``cmap='color_name'`` (see the :ref:`colormaps section <ug_cmaps>` for more info).
189+
# You can also create on-the-fly "qualitative" `~proplot.colors.DiscreteColormap`\ s
190+
# by passing lists of colors to the keyword `c`, `color`, or `colors`.
191191
#
192192
# In matplotlib, data values are translated into
193193
# colormap colors using so-called `colormap "normalizers"
194194
# <https://matplotlib.org/stable/tutorials/colors/colormapnorms.html>`__.
195195
# A normalizer can be selected from its "registered" name using the
196196
# `~proplot.constructor.Norm` :ref:`constructor function <why_constructor>`. You
197-
# can also build a normalizer on-the-fly using the `norm` and `norm_kw` keywords.
197+
# can also build a normalizer on-the-fly using the `norm` and `norm_kw` keywords,
198+
# again available with most `~proplot.axes.PlotAxes` 2d plotting commands.
198199
# If you want to work with normalizer classes directly, they are also imported
199200
# into the top-level namespace (e.g., ``pplt.LogNorm(...)`` is allowed). To
200201
# explicitly set the normalization range, you can pass the usual `vmin` and `vmax`

docs/basics.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
# ----------------
2727
#
2828
# ProPlot works by creating a `proplot.figure.Figure` subclass of
29-
# `matplotlib.figure.Figure`, an `proplot.axes.Axes` subclass of
30-
# `matplotlib.axes.Axes`, and determining subplot locations using a
31-
# `proplot.gridspec.GridSpec` subclass of `matplotlib.gridspec.GridSpec`
29+
# `matplotlib.figure.Figure`, an `proplot.axes.Axes` and `proplot.axes.PlotAxes`
30+
# subclass of `matplotlib.axes.Axes`, and determining subplot locations using
31+
# a `proplot.gridspec.GridSpec` subclass of `matplotlib.gridspec.GridSpec`
3232
# (for more on gridspecs, see this `matplotlib tutorial
3333
# <https://matplotlib.org/stable/tutorials/intermediate/gridspec.html>`__).
3434
#
@@ -91,19 +91,22 @@
9191
# Creating subplots
9292
# -----------------
9393
#
94-
# Similar to matplotlib, subplots can be added to figures one-by-one or all
95-
# at once. To add subplots all at once, use the `~proplot.figure.Figure.add_subplots`
96-
# or `~proplot.figure.Figure.subplots` commands.
94+
# Similar to matplotlib, `proplot.axes.Axes` can be added to figures
95+
# one-by-one or all at once. To add subplots all at once, use the
96+
# `~proplot.figure.Figure.add_subplots` or `~proplot.figure.Figure.subplots`
97+
# commands. Note that under the hood, `~proplot.ui.subplots` simply calls
98+
# `~proplot.ui.figure` followed by `proplot.figure.Figure.add_subplots`.
9799
#
98-
# * With no arguments, `~proplot.figure.Figure.add_subplots` returns a figure
99-
# with a single subplot.
100+
# * With no arguments, `~proplot.figure.Figure.add_subplots` returns single
101+
# subplot generated from a 1-column, 1-row `~proplot.gridspec.GridSpec`.
100102
# * With `ncols` or `nrows`, `~proplot.figure.Figure.add_subplots` returns a
101-
# figure with a simple grid of subplots.
102-
# * With `array`, `~proplot.figure.Figure.add_subplots` returns a figure with
103-
# an arbitrarily complex grid of subplots. `array` is a 2D array representing
104-
# a "picture" of the subplot layout, where each unique integer indicates a
105-
# `~matplotlib.gridspec.GridSpec` slot that is occupied by the corresponding
106-
# subplot and ``0`` indicates an empty space.
103+
# simple grid of subplots from a `~proplot.gridspec.GridSpec` with
104+
# matching geometry in either row-major or column-major `order`.
105+
# * With `array`, `~proplot.figure.Figure.add_subplots` returns an arbitrarily
106+
# complex grid of subplots from a `~proplot.gridspec.GridSpec` with matching
107+
# geometry. Here `array` is a 2D array representing a "picture" of the subplot
108+
# layout, where each unique integer indicates a `~matplotlib.gridspec.GridSpec` slot
109+
# that is occupied by the corresponding subplot and ``0`` indicates an empty space.
107110
#
108111
# To add subplots one-by-one, use the `proplot.figure.Figure.add_subplot`
109112
# or `proplot.figure.Figure.subplot` commands.
@@ -221,9 +224,10 @@
221224
# an object-oriented interface and a MATLAB-style `~matplotlib.pyplot` interface
222225
# (which uses the object-oriented interface internally). Plotting with ProPlot is just
223226
# like plotting with matplotlib's *object-oriented* interface. ProPlot builds upon
224-
# the `proplot.axes.Axes` base class with a `proplot.axes.PlotAxes` subclass
225-
# that adds new plotting commands and new features to existing commands. These
226-
# additions do not change the usage or syntax of existing commands, which
227+
# the `~matplotlib.axes.Axes` class with a `proplot.axes.PlotAxes` subclass, used
228+
# with every axes generated by ProPlot. The `~proplot.axes.PlotAxes subclass`
229+
# adds several new plotting commands and adds new features to existing commands.
230+
# These additions do not change the usage or syntax of existing commands, which
227231
# means a shallow learning curve for the average matplotlib user.
228232
#
229233
# In the below example, we create a 4-panel figure with the familiar matplotlib

proplot/gridspec.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"""
33
The gridspec and subplotspec subclasses.
44
"""
5-
import functools
65
import itertools
6+
from functools import partial
77

88
import matplotlib.axes as maxes
99
import matplotlib.gridspec as mgridspec
@@ -69,8 +69,8 @@
6969
Whether to make the tight layout algorithm apply equal spacing between columns,
7070
rows, or both. Default is ``False``. Ignored if :rcraw:`tight` is ``False``.
7171
outerpad : float or str, optional
72-
The tight layout padding around edge of figure. Units are interpreted
73-
by `~proplot.utils.units`. Default is :rc:`subplots.outerpad`.
72+
The tight layout padding around the left, right, top, and bottom edges
73+
of the figure. Default is :rc:`subplots.outerpad`.
7474
%(units.em)s
7575
innerpad : float or str, optional
7676
The scalar tight layout padding between columns and rows. Synonymous with
@@ -83,7 +83,7 @@
8383
"""
8484
docstring.snippets['gridspec.shared'] = docstring.add_snippets(_shared_docstring)
8585
docstring.snippets['gridspec.scalar'] = docstring.add_snippets(_scalar_docstring)
86-
docstring.snippets['gridspec.vector'] = docstring.add_snippets(_tight_docstring)
86+
docstring.snippets['gridspec.vector'] = docstring.add_snippets(_vector_docstring)
8787
docstring.snippets['gridspec.tight'] = docstring.add_snippets(_tight_docstring)
8888

8989

@@ -1112,14 +1112,14 @@ def figure(self, fig):
11121112
# obfuscation makes this confusing. For example gs.update(wspace=gs.wspace) in
11131113
# presence of panels would yield error. For now the only supported introspection
11141114
# is the __repr__. Probably no big deal... introspection not critical here.
1115-
nrows = property(lambda self: self._nrows) # in case missing
1116-
ncols = property(lambda self: self._ncols) # ...
1117-
left = property(functools.partial(_get_current_space, key='left'))
1118-
bottom = property(functools.partial(_get_current_space, key='bottom'))
1119-
right = property(functools.partial(_get_current_space, key='right'))
1120-
top = property(functools.partial(_get_current_space, key='top'))
1121-
hspace = property(functools.partial(_get_current_space, key='hspace'))
1122-
wspace = property(functools.partial(_get_current_space, key='wspace'))
1115+
nrows = property(lambda self: self._nrows, doc='') # in case missing
1116+
ncols = property(lambda self: self._ncols, doc='') # ...
1117+
left = property(partial(_get_current_space, key='left'), doc='')
1118+
bottom = property(partial(_get_current_space, key='bottom'), doc='')
1119+
right = property(partial(_get_current_space, key='right'), doc='')
1120+
top = property(partial(_get_current_space, key='top'), doc='')
1121+
hspace = property(partial(_get_current_space, key='hspace'), doc='')
1122+
wspace = property(partial(_get_current_space, key='wspace'), doc='')
11231123
hpad = property(lambda self: list(self._hpad)) # copy for consistency
11241124
wpad = property(lambda self: list(self._wpad)) # ...
11251125
hratios = property(lambda self: list(self._hratios))

0 commit comments

Comments
 (0)