Skip to content

Commit 4b0b0f2

Browse files
committed
Update docs for clarity + brevity
1 parent e04f6ab commit 4b0b0f2

File tree

3 files changed

+64
-63
lines changed

3 files changed

+64
-63
lines changed

docs/2dplots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
# %% [raw]
9595
# .. _ug_2dintegration:
9696
#
97-
# Pandas, xarray, and pint integration
98-
# ------------------------------------
97+
# Pandas and xarray integration
98+
# -----------------------------
9999
#
100100
# The `~proplot.axes.PlotAxes` plotting commands are seamlessly integrated
101101
# with `pandas`_ and `xarray`_. If you omit *x* and *y* coordinates, the

docs/basics.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@
220220
# `two different interfaces <https://matplotlib.org/stable/api/index.html>`__:
221221
# an object-oriented interface and a MATLAB-style `~matplotlib.pyplot` interface
222222
# (which uses the object-oriented interface internally). Plotting with ProPlot is just
223-
# like plotting with matplotlib's *object-oriented* interface. Proplot builds upon
224-
# the `proplot.axes.Axes` base class with an intermediate `proplot.axes.PlotAxes`
225-
# subclass that adds new plotting commands and new features to existing plotting
226-
# commands. These additions do not change the usage or syntax of existing commands,
227-
# which means a shallow learning curve for the average matplotlib user.
223+
# 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+
# means a shallow learning curve for the average matplotlib user.
228228
#
229229
# In the below example, we create a 4-panel figure with the familiar matplotlib
230-
# commands `~prplot.axes.PlotAxes.plot`, `~prplot.axes.PlotAxes.scatter`,
231-
# `~prplot.axes.PlotAxes.pcolormesh`, and `~prplot.axes.PlotAxes.contourf`.
230+
# commands `~proplot.axes.PlotAxes.plot`, `~proplot.axes.PlotAxes.scatter`,
231+
# `~proplot.axes.PlotAxes.pcolormesh`, and `~proplot.axes.PlotAxes.contourf`.
232232
# See the :ref:`1d plotting <ug_1dplots>` and :ref:`2d plotting <ug_2dplots>`
233233
# sections for details on the features added by ProPlot.
234234

@@ -266,14 +266,12 @@
266266
# ``format`` method. This is your one-stop-shop for changing axes settings.
267267
# Keyword arguments passed to ``format`` are interpreted as follows:
268268
#
269-
# .. rst-class:: dummy-line-break-class
270-
#
271-
# #. Any keyword matching the name of an `~proplot.config.rc` setting
269+
# 1. Any keyword matching the name of an `~proplot.config.rc` setting
272270
# is used to update the axes. If the name has "dots", you can omit them
273271
# (e.g., ``titleloc='left'`` changes the :rcraw:`title.loc` property).
274272
# See the :ref:`configuration section <ug_config>` for details.
275273
#
276-
# #. Valid keywords arguments are passed to
274+
# 2. Valid keywords arguments are passed to
277275
# `proplot.axes.CartesianAxes.format`, `proplot.axes.PolarAxes.format`,
278276
# or `proplot.axes.GeoAxes.format`. These change settings that are
279277
# specific to the axes type. For example:
@@ -285,9 +283,7 @@
285283
# * To change the meridional bounds on a `~proplot.axes.GeoAxes`,
286284
# use e.g. ``lonlim=(-90, 0)``.
287285
#
288-
# .. rst-class:: dummy-line-break-class
289-
#
290-
# #. Remaining keyword arguments are passed to the base `proplot.axes.Axes.format`
286+
# 3. Remaining keyword arguments are passed to the base `proplot.axes.Axes.format`
291287
# method. `~proplot.axes.Axes` is the base class for all other axes classes.
292288
# This changes things that are the same for all axes types, like titles and
293289
# a-b-c subplot labels (e.g., ``title='Title'``).
@@ -296,8 +292,9 @@
296292
# of settings at once, instead of one-liner setter methods like
297293
# ``ax.set_title()`` and ``ax.set_xlabel()``. They are also integrated with
298294
# the `~proplot.constructor.Locator`, `~proplot.constructor.Formatter`,
299-
# and `~proplot.constructor.Scale` :ref:`constructor functions <why_constructor>`
300-
# (see :ref:`this section <ug_cartesian>`).
295+
# and `~proplot.constructor.Scale` :ref:`constructor functions <ug_cartesian>`.
296+
# You can also call ``format`` for several subplots at once using
297+
# `proplot.figure.Figure.format` or `proplot.figure.SubplotGrid.format` (see below).
301298
#
302299
# The below example shows the many different keyword arguments accepted by
303300
# ``format``, and demonstrates how ``format`` can be used to succinctly and
@@ -341,7 +338,7 @@
341338
# unifies these three possible return values:
342339
#
343340
# * `~proplot.figure.SubplotGrid` permits array-like 2D indexing, e.g.
344-
# ``axs[1, 0]``. Indexing the ~proplot.figure.SubplotGrid` is similar
341+
# ``axs[1, 0]``. Indexing the `~proplot.figure.SubplotGrid` is similar
345342
# to indexing a `~proplot.gridspec.GridSpec`. The result is a
346343
# `~proplot.figure.SubplotGrid` of subplots that occupy the indexed
347344
# `~proplot.gridspec.GridSpec` slot(s).
@@ -358,7 +355,7 @@
358355
# property. `~proplot.figure.SubplotGrid` is especially useful because it lets you
359356
# call ``format``, ``colorbar``, ``legend``, ``panel``, ``inset``, and the various
360357
# twin axis commands simultaneously for all subplots in the grid. In the below
361-
# example, we use the `proplot.figure.SubplotGrid.format` command on the grid
358+
# example, we use `~proplot.figure.SubplotGrid.format` command on the grid
362359
# returned by `~proplot.ui.subplots` to format several subplots all at once.
363360

364361
# %%

docs/projections.py

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# Geographic and polar plots
2727
# ==========================
2828
#
29-
# ProPlot includes several advanced features for working with
30-
# `polar <polar_>`_ and :ref:`geographic projections <ug_geo>`.
29+
# ProPlot includes several advanced features for working with `polar`_
30+
# and :ref:`geographic projections <ug_geo>`.
3131
#
3232
# To change the axes projection, pass ``proj='name'`` to an axes-creation command
3333
# (i.e., `~proplot.figure.Figure.add_subplot`, `~proplot.figure.Figure.add_subplots`,
@@ -37,27 +37,49 @@
3737
# or a dictionary of projection names with the subplot number as the key. For example,
3838
# a 2-column figure with a Cartesian axes on the left and a Plate Carrée projection
3939
# on the right can be built with either ``proj=('cartesian', 'pcarree')`` or
40-
# ``proj={2: 'pcarree'}``. The default "projection" is `~proplot.axes.CartesianAxes`
41-
# and can be explicitly specified with the ``'cartesian'`` key.
40+
# ``proj={2: 'pcarree'}``. The default projection is `~proplot.axes.CartesianAxes`,
41+
# specified with the key ``'cartesian'``.
4242

4343
# %% [raw] raw_mimetype="text/restructuredtext"
4444
# .. _ug_geo:
4545
#
4646
# Geographic axes
4747
# ---------------
4848
#
49-
# Geographic plots can be created in ProPlot using either `cartopy`_ or `basemap`_
50-
# as "backends". Note that this feature is *optional* -- installation of cartopy
51-
# or basemap is not required. To create geographic axes, pass
52-
# e.g. ``proj='name'`` to an axes-creation command (see :ref:`above <ug_proj>`)
53-
# where ``name`` is any valid :ref:`PROJ projection name <proj_included>`.
54-
# Alternatively, you can use ``proj=projection_instance`` where ``projection_instance``
55-
# is a `cartopy.crs.Projection` or `mpl_toolkits.basemap.Basemap` generated with
49+
# To create geographic axes, pass e.g. ``proj='name'`` to an axes-creation
50+
# command (see :ref:`above <ug_proj>`) where ``name`` is any valid
51+
# :ref:`PROJ projection name <proj_included>`. Alternatively, you can use
52+
# ``proj=projection_instance`` where ``projection_instance`` is a
53+
# `cartopy.crs.Projection` or `mpl_toolkits.basemap.Basemap` generated with
5654
# the `~proplot.constructor.Proj` :ref:`constructor function <why_constructor>`.
55+
# A very simple geographic plot is shown below.
56+
57+
# %%
58+
# Option A: Create a projection with pplt.Proj()
59+
# import proplot as plot
60+
# proj = pplt.Proj('robin', lon_0=180)
61+
# fig, axs = pplt.subplots(nrows=2, refwidth=3, proj=proj)
62+
63+
# Option B: Create an on-the-fly projection
64+
import proplot as pplt
65+
fig = pplt.figure(refwidth=3)
66+
axs = fig.subplots(nrows=2, proj='robin', proj_kw={'lon_0': 180})
67+
axs.format(
68+
suptitle='Figure with single projection',
69+
coast=True, latlines=30, lonlines=60,
70+
)
71+
72+
# %% [raw] raw_mimetype="text/restructuredtext"
73+
# .. _ug_backends:
74+
#
75+
# Cartopy and basemap
76+
# -------------------
5777
#
78+
# Geographic axes in ProPlot use either `cartopy`_ or `basemap`_ as "backends".
5879
# When you request a geographic projection, the axes-creation command returns
59-
# a `proplot.axes.GeoAxes` instance(s). This `~proplot.axes.Axes` subclass has its
60-
# own `~proplot.axes.GeoAxes.format` command that :ref:`manages geographic features
80+
# a `proplot.axes.GeoAxes` instance(s) that uses either cartopy or basemap
81+
# under the hood. The `proplot.axes.GeoAxes` subclass has its own
82+
# `~proplot.axes.GeoAxes.format` command that :ref:`manages geographic features
6183
# <ug_geoformat>` like meridional and parallel gridlines and land mass outlines
6284
# with the same syntax for either backend. A few details:
6385
#
@@ -89,11 +111,11 @@
89111
# available via the `~proplot.axes.GeoAxes.projection` attribute.
90112
#
91113
# Together, these features let you work with geophysical data without invoking
92-
# verbose cartopy classes like `~cartopy.crs.LambertAzimuthalEqualArea` and
93-
# `~cartopy.feature.NaturalEarthFeature` or keeping track of separate
94-
# `~mpl_toolkits.basemap.Basemap` instances. They considerably reduce the amount of
95-
# code needed to make geographic plots. In the below examples, we create a variety
96-
# of geographic plots using both cartopy and basemap as backends.
114+
# verbose cartopy classes like `~cartopy.crs.LambertAzimuthalEqualArea`
115+
# or keeping track of separate `~mpl_toolkits.basemap.Basemap` instances. They
116+
# considerably reduce the amount of code needed to make geographic plots.
117+
# In the below examples, we create a variety of geographic plots using both
118+
# cartopy and basemap as backends.
97119
#
98120
# .. note::
99121
#
@@ -115,31 +137,13 @@
115137
# of `central_longitude`) and instantiates `~mpl_toolkits.basemap.Basemap`
116138
# projections with sensible default PROJ parameters rather than raising an error
117139
# when they are omitted (e.g., ``lon_0=0`` as the default for most projections).
118-
#
119-
# .. warning::
120-
#
121-
# Basemap is `no longer maintained \
122-
# <https://matplotlib.org/basemap/users/intro.html#cartopy-new-management-and-eol-announcement>`__
123-
# and will not work with matplotlib versions more recent than 3.2.2. However,
124-
# as shown below, gridline labels often look nicer in basemap than cartopy --
125-
# especially when "inline" cartopy labels are disabled. This is the main reason
126-
# ProPlot continues to support basemap. When cartopy gridline labels improve,
127-
# basemap support may be deprecated.
128-
129-
# %%
130-
# Option A: Create a projection with pplt.Proj()
131-
# import proplot as plot
132-
# proj = pplt.Proj('robin', lon_0=180)
133-
# fig, axs = pplt.subplots(nrows=2, refwidth=3, proj=proj)
134-
135-
# Option B: Create an on-the-fly projection
136-
import proplot as pplt
137-
fig = pplt.figure(refwidth=3)
138-
axs = fig.subplots(nrows=2, proj='robin', proj_kw={'lon_0': 180})
139-
axs.format(
140-
suptitle='Figure with single projection',
141-
coast=True, latlines=30, lonlines=60,
142-
)
140+
# * Basemap is `no longer maintained \
141+
# <https://matplotlib.org/basemap/users/intro.html#cartopy-new-management-and-eol-announcement>`__
142+
# and will not work with matplotlib versions more recent than 3.2.2. However,
143+
# basemap gridline labels often look nicer than cartopy -- especially when
144+
# "inline" cartopy labels are disabled. This is the main reason ProPlot continues
145+
# to support basemap. When cartopy gridline labels improve, basemap support
146+
# may be deprecated.
143147

144148
# %%
145149
import proplot as pplt

0 commit comments

Comments
 (0)