Skip to content

Commit c6a1dad

Browse files
committed
Cleanup docs and add PlotAxes references
1 parent 337607b commit c6a1dad

File tree

13 files changed

+153
-143
lines changed

13 files changed

+153
-143
lines changed

WHATSNEW.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Bug fixes
222222
* Fix issue where `vmin` and `vmax` are ignored when making plots
223223
with discrete levels (:issue:`276`).
224224
* Fix issue where `autodiverging` is disabled even when known diverging colormaps
225-
are passed to plotting commands (:commit:`2eca2198`).
225+
are passed to `~proplot.axes.PlotAxes` commands (:commit:`2eca2198`).
226226
* Fix issue where colormaps made with `~proplot.constructor.Colormap` with unspecified
227227
`name` cannot be assigned as `~proplot.config.rc` defaults (:commit:`0e93b7fa`).
228228
* Fix issue where registered colormaps with trailing ``_r`` or ``_s`` cannot be

docs/1dplots.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# Standardized arguments
4040
# ----------------------
4141
#
42-
# Data arguments passed to 1D plot commands are now uniformly
42+
# Data arguments passed to 1D `~proplot.axes.PlotAxes` commands are uniformly
4343
# standardized. For each command, you can optionally omit the dependent
4444
# variable coordinates, in which case they are inferred from the data
4545
# (see :ref:`xarray and pandas integration <ug_1dintegration>`), or pass
@@ -53,15 +53,14 @@
5353
#
5454
# .. note::
5555
#
56-
# By default, when just the *x* or *y* axis was explicitly fixed by
57-
# `~matplotlib.axes.Axes.set_xlim` or `~matplotlib.axes.Axes.set_ylim`
58-
# (or, equivalently, by passing `xlim` or `ylim` to
59-
# `proplot.axes.CartesianAxes.format`), proplot ignores the out of bounds
60-
# data when determining the other axis limits. This can be useful if
61-
# you wish to restrict the view within a large dataset. To disable
62-
# this feature, pass ``inbounds=False`` to the plotting command or set
63-
# :rcraw:`axes.inbounds` to ``False`` (see also the :rcraw:`cmap.inbounds`
64-
# setting and the :ref:`user guide <ug_2dstd>`).
56+
# By default, when choosing default values for the *x* or *y* axis limits,
57+
# proplot ignores out-of-bounds data along the other axis if it was explicitly
58+
# fixed by `~matplotlib.axes.Axes.set_xlim` or `~matplotlib.axes.Axes.set_ylim` (or,
59+
# equivalently, by passing `xlim` or `ylim` to `proplot.axes.CartesianAxes.format`).
60+
# This can be useful if you wish to restrict the view along a "dependent" variable
61+
# axis within a large dataset. To disable this feature, pass ``inbounds=False`` to
62+
# the plotting command or set :rcraw:`axes.inbounds` to ``False`` (see also
63+
# the :rcraw:`cmap.inbounds` setting and the :ref:`user guide <ug_2dstd>`).
6564

6665
# %%
6766
import proplot as pplt
@@ -132,13 +131,13 @@
132131
# Pandas and xarray integration
133132
# -----------------------------
134133
#
135-
# The `~proplot.axes.PlotAxes` plotting commands recognize `pandas`_
134+
# The 1D `~proplot.axes.PlotAxes` commands recognize `pandas`_
136135
# and `xarray`_ data structures. If you omit dependent variable coordinates,
137-
# the plotting commands try to infer them from the `pandas.Series`, `pandas.DataFrame`,
136+
# the commands try to infer them from the `pandas.Series`, `pandas.DataFrame`,
138137
# or `xarray.DataArray`. If you did not explicitly set the *x* or *y* axis label
139-
# or :ref:`legend or colorbar <ug_guides_loc>` label(s), the plotting commands
138+
# or :ref:`legend or colorbar <ug_guides_loc>` label(s), the commands
140139
# try to retrieve them from the `pandas.DataFrame` or `xarray.DataArray`.
141-
# The plotting commands also recognize `pint.Quantity` structures and apply
140+
# The commands also recognize `pint.Quantity` structures and apply
142141
# unit string labels with formatting specified by :rc:`unitformat`.
143142
#
144143
# These features restore some of the convenience you get with the builtin
@@ -220,7 +219,7 @@
220219
# <https://matplotlib.org/stable/tutorials/intermediate/color_cycle.html#sphx-glr-tutorials-intermediate-color-cycle-py>`__
221220
# on-the-fly and use different property cycles for different plot elements.
222221
# You can do so using the `cycle` and `cycle_kw` keywords, available
223-
# with most `~proplot.axes.PlotAxes` 1D plot commands. `cycle` and `cycle_kw` are
222+
# with most 1D `~proplot.axes.PlotAxes` commands. `cycle` and `cycle_kw` are
224223
# passed to the `~proplot.constructor.Cycle` :ref:`constructor function
225224
# <why_constructor>`, and the resulting property cycle is used for the plot. You
226225
# can specify `cycle` once with 2D input data (in which case each column is
@@ -572,10 +571,10 @@
572571
# `~proplot.axes.PlotAxes.fill_between`, `~proplot.axes.PlotAxes.fill_betweenx`
573572
# (shorthands `~proplot.axes.PlotAxes.area`, `~proplot.axes.PlotAxes.areax`),
574573
# `~proplot.axes.PlotAxes.vlines`, `~proplot.axes.PlotAxes.hlines`,
575-
# `~proplot.axes.PlotAxes.bar`, or `~proplot.axes.PlotAxes.barh` plotting commands.
576-
# The default negative and positive colors are controlled with :rcraw:`negcolor`
577-
# and :rcraw:`poscolor` but the colors can be modified for particular plots by
578-
# passing ``negcolor=color`` and ``poscolor=color`` to the plotting commands.
574+
# `~proplot.axes.PlotAxes.bar`, or `~proplot.axes.PlotAxes.barh` commands.
575+
# The default negative and positive colors are controlled with :rcraw:`negcolor` and
576+
# :rcraw:`poscolor` but the colors can be modified for particular plots by passing
577+
# ``negcolor=color`` and ``poscolor=color`` to the `~proplot.axes.PlotAxes` commands.
579578

580579
# %%
581580
import proplot as pplt

docs/2dplots.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@
3434
#
3535
# .. important::
3636
#
37-
# By default, proplot automatically adjusts the line width of patch edges to
38-
# eliminate the appearance of `"white lines" in saved vector graphic files
39-
# <https://github.com/jklymak/contourfIssues>`__. However, this behavior
40-
# can significantly slow down the drawing and saving time for large datasets.
41-
# To disable this behavior, pass ``edgefix=False`` to `~proplot.axes.PlotAxes`
42-
# commands like `~proplot.axes.PlotAxes.pcolor`, or set :rcraw:`edgefix`
43-
# to ``False`` to disable globally.
37+
# By default, proplot automatically adjusts the width of
38+
# `~proplot.axes.PlotAxes.contourf` and `~proplot.axes.PlotAxes.pcolor` edges
39+
# to eliminate the appearance of `"white lines" in saved vector graphic files
40+
# <https://github.com/jklymak/contourfIssues>`__. However, this can significantly
41+
# slow down the drawing time for large datasets. To disable this feature,
42+
# pass ``edgefix=False`` to the relevant `~proplot.axes.PlotAxes` command,
43+
# or set :rcraw:`edgefix` to ``False`` to disable globally.
4444

4545
# %% [raw] raw_mimetype="text/restructuredtext"
4646
# .. _ug_2dstd:
4747
#
4848
# Standardized arguments
4949
# ----------------------
5050
#
51-
# Data arguments passed to 2D plot commands are now uniformly
51+
# Data arguments passed to 2D `~proplot.axes.PlotAxes` commands are uniformly
5252
# standardized. For each command, you can optionally omit the *x* and
5353
# *y* coordinates, in which case they are inferred from the data
5454
# (see :ref:`xarray and pandas integration <ug_2dintegration>`). If coordinates
@@ -66,15 +66,15 @@
6666
#
6767
# .. note::
6868
#
69-
# By default, when proplot selects the default colormap :ref:`normalization
70-
# range <ug_apply_cmap>`, it ignores data outside the *x* or *y* axis limits
71-
# if they were previously fixed by `~matplotlib.axes.Axes.set_xlim` or
69+
# By default, when choosing a default colormap :ref:`normalization
70+
# range <ug_apply_cmap>`, proplot ignores data outside the *x* or *y* axis
71+
# limits if they were previously fixed by `~matplotlib.axes.Axes.set_xlim` or
7272
# `~matplotlib.axes.Axes.set_ylim` (or, equivalently, by passing `xlim` or
7373
# `ylim` to `proplot.axes.CartesianAxes.format`). This can be useful if you
74-
# wish to restrict the view within a large dataset. To disable this feature,
75-
# pass ``inbounds=False`` to the plotting command or set :rcraw:`cmap.inbounds`
76-
# to ``False`` (see also the :rcraw:`axes.inbounds` setting and the
77-
# :ref:`user guide <ug_1dstd>`).
74+
# wish to restrict the view along the *x* or *y* axis within a large dataset.
75+
# To disable this feature, pass ``inbounds=False`` to the plotting command or
76+
# set :rcraw:`cmap.inbounds` to ``False`` (see also the :rcraw:`axes.inbounds`
77+
# setting and the :ref:`user guide <ug_1dstd>`).
7878

7979
# %%
8080
import proplot as pplt
@@ -146,13 +146,13 @@
146146
# Pandas and xarray integration
147147
# -----------------------------
148148
#
149-
# The `~proplot.axes.PlotAxes` plotting commands recognize `pandas`_
149+
# The 2D `~proplot.axes.PlotAxes` commands recognize `pandas`_
150150
# and `xarray`_ data structures. If you omit *x* and *y* coordinates,
151-
# the plotting commands try to infer them from the `pandas.DataFrame` or
151+
# the commands try to infer them from the `pandas.DataFrame` or
152152
# `xarray.DataArray`. If you did not explicitly set the *x* or *y* axis label
153-
# or :ref:`legend or colorbar <ug_guides_loc>` label(s), the plotting commands
153+
# or :ref:`legend or colorbar <ug_guides_loc>` label(s), the commands
154154
# try to retrieve them from the `pandas.DataFrame` or `xarray.DataArray`.
155-
# The plotting commands also recognize `pint.Quantity` structures and apply
155+
# The commands also recognize `pint.Quantity` structures and apply
156156
# unit string labels with formatting specified by :rc:`unitformat`.
157157
#
158158
# These features restore some of the convenience you get with the builtin
@@ -324,7 +324,7 @@
324324
# you can select the normalizer from its "registered" name using the
325325
# `~proplot.constructor.Norm` :ref:`constructor function <why_constructor>`. You
326326
# can also build a normalizer on-the-fly using the `norm` and `norm_kw` keywords,
327-
# available with most `~proplot.axes.PlotAxes` 2D plot commands.
327+
# available with most 2D `~proplot.axes.PlotAxes` commands.
328328
# If you want to work with the normalizer classes directly, they are available in
329329
# the top-level namespace (e.g., ``norm=pplt.LogNorm(...)`` is allowed). To
330330
# explicitly set the normalization range, you can pass the usual `vmin` and `vmax`
@@ -435,8 +435,8 @@
435435
# ---------------
436436
#
437437
# By default, proplot uses `~proplot.colors.DiscreteNorm` to "discretize"
438-
# the possible colormap colors for contour and pseudocolor plotting commands
439-
# (e.g., `~proplot.axes.PlotAxes.contourf`, `~proplot.axes.PlotAxes.pcolor`).
438+
# the possible colormap colors for contour and pseudocolor `~proplot.axes.PlotAxes`
439+
# commands (e.g., `~proplot.axes.PlotAxes.contourf`, `~proplot.axes.PlotAxes.pcolor`).
440440
# This is analogous to `matplotlib.colors.BoundaryNorm`, except
441441
# `~proplot.colors.DiscreteNorm` can be paired with arbitrary
442442
# continuous normalizers specified by `norm` (see :ref:`above <ug_norm>`).
@@ -542,8 +542,8 @@
542542
#
543543
# Additionally, `similar to xarray
544544
# <http://xarray.pydata.org/en/stable/user-guide/plotting.html#colormaps>`__,
545-
# proplot can automatically detect "diverging" datasets. By default, the
546-
# `~proplot.axes.PlotAxes` 2D plot commands will apply the diverging colormap
545+
# proplot can automatically detect "diverging" datasets. By default,
546+
# the 2D `~proplot.axes.PlotAxes` commands will apply the diverging colormap
547547
# :rc:`cmap.diverging` (rather than :rc:`cmap.sequential`) and the diverging
548548
# normalizer `~proplot.colors.DivergingNorm` (rather than `~matplotlib.colors.Normalize`
549549
# -- see :ref:`above <ug_norm>`) if the following conditions are met:

docs/colorbars_legends.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@
109109
# --------------------------------
110110
#
111111
# In proplot, you can add colorbars and legends on-the-fly by supplying keyword
112-
# arguments to various plotting commands. To plot data and draw a colorbar or legend
113-
# in one go, pass a location (e.g., ``colorbar='r'`` or ``legend='b'``) to the plotting
114-
# command (e.g., `~proplot.axes.PlotAxes.plot` or `~proplot.axes.PlotAxes.contour`).
115-
# To pass keyword arguments to the colorbar and legend commands, use the `legend_kw`
116-
# and `colorbar_kw` arguments (e.g., ``legend_kw={'ncol': 3}``). Note that
117-
# `~proplot.axes.Axes.colorbar` can also build colorbars from lists of
118-
# arbitrary matplotlib artists, for example the lines generated by
119-
# `~proplot.axes.PlotAxes.plot` (see :ref:`below <ug_colorbars>`).
112+
# arguments to various `~proplot.axes.PlotAxes` commands. To plot data and
113+
# draw a colorbar or legend in one go, pass a location (e.g., ``colorbar='r'``
114+
# or ``legend='b'``) to the plotting command (e.g., `~proplot.axes.PlotAxes.plot`
115+
# or `~proplot.axes.PlotAxes.contour`). To pass keyword arguments to the colorbar
116+
# and legend commands, use the `legend_kw` and `colorbar_kw` arguments (e.g.,
117+
# ``legend_kw={'ncol': 3}``). Note that `~proplot.axes.Axes.colorbar` can also
118+
# build colorbars from lists of arbitrary matplotlib artists, for example the lines
119+
# generated by `~proplot.axes.PlotAxes.plot` (see :ref:`below <ug_colorbars>`).
120120
#
121121
# .. note::
122122
#
@@ -271,8 +271,8 @@
271271
# * Calling ``colorbar`` with a list of `~matplotlib.artist.Artist`\ s,
272272
# a `~matplotlib.colors.Colormap` name or object, or a list of colors
273273
# will build the required `~matplotlib.cm.ScalarMappable` on-the-fly. Lists
274-
# of `~matplotlib.artist.Artists`\ s are used when you use the `colorbar` keyword
275-
# with :ref:`1D plot commands <ug_1dplots>` like `~proplot.axes.PlotAxes.plot`.
274+
# of `~matplotlib.artist.Artists`\ s are used when you use the `colorbar`
275+
# keyword with :ref:`1D commands <ug_1dplots>` like `~proplot.axes.PlotAxes.plot`.
276276
# * The associated :ref:`colormap normalizer <ug_norm>` can be specified with the
277277
# `vmin`, `vmax`, `norm`, and `norm_kw` keywords. The `~proplot.colors.DiscreteNorm`
278278
# levels can be specified with `values`, or proplot will infer them from the

docs/colormaps.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,11 @@
153153
# Making colormaps
154154
# ----------------
155155
#
156-
# Proplot doesn't just include new colormaps -- it provides tools
157-
# for merging colormaps, modifying existing colormaps, making new
158-
# :ref:`perceptually uniform colormaps <ug_perceptual>`, and saving colormaps
159-
# for future use. Most of these features can be accessed via the
156+
# Proplot includes tools for merging colormaps, modifying existing colormaps,
157+
# making new :ref:`perceptually uniform colormaps <ug_perceptual>`, and
158+
# saving colormaps for future use. Most of these features can be accessed via the
160159
# `~proplot.constructor.Colormap` :ref:`constructor function <why_constructor>`.
161-
# Note that every plotting command that accepts a `cmap` keyword passes
160+
# Note that every `~proplot.axes.PlotAxes` command that accepts a `cmap` keyword passes
162161
# it through this function (see the :ref:`2D plotting section <ug_apply_cmap>`).
163162
#
164163
# To make `~proplot.colors.PerceptualColormap`\ s from
@@ -270,7 +269,7 @@
270269
# In the below example, we create a new divering colormap and
271270
# reconstruct the colormap from `this SciVisColor example
272271
# <https://sciviscolor.org/media/filer_public/c7/27/c727e638-82eb-445b-bc96-e7b64c13efa2/colormoves.png>`__.
273-
# We also *save* the results for future use by passing ``save=True`` to
272+
# We also save the results for future use by passing ``save=True`` to
274273
# `~proplot.constructor.Colormap`.
275274

276275
# %%

docs/cycles.py

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# used with distinct plot elements like lines and bars. Occasionally,
2525
# they are used with categorical data as "qualitative" colormaps. Proplot's
2626
# color cycles are registered as `~proplot.colors.DiscreteColormap`\ s,
27-
# and can be converted into `property cyclers
27+
# and can be easily converted into `property cyclers
2828
# <https://matplotlib.org/stable/tutorials/intermediate/color_cycle.html>`__
2929
# for use with distinct plot elements using the `~proplot.constructor.Cycle`
3030
# constructor function. `~proplot.constructor.Cycle` can also
@@ -60,13 +60,13 @@
6060
# Changing the color cycle
6161
# ------------------------
6262
#
63-
# Various plotting commands like `~proplot.axes.PlotAxes.line` and
64-
# `~proplot.axes.PlotAxes.scatter` now accept a `cycle` keyword
65-
# passed to the `~proplot.constructor.Cycle` constructor function
66-
# (see the :ref:`1D plotting section <ug_apply_cycle>`). To save
67-
# your color cycle data and use it every time proplot is imported, simply pass
68-
# ``save=True`` to `~proplot.constructor.Cycle`. If you want to change the global
69-
# property cycler, pass a `~proplot.colors.DiscreteColormap` or colormap name
63+
# Most 1D `~proplot.axes.PlotAxes` commands like `~proplot.axes.PlotAxes.line`
64+
# and `~proplot.axes.PlotAxes.scatter` accept a `cycle` keyword (see the
65+
# :ref:`1D plotting section <ug_apply_cycle>`). This can be used to change the
66+
# color cycle on-the-fly, whether plotting with successive calls to
67+
# `~proplot.axes.PlotAxes` commands or a single call using 2D array(s) (see
68+
# the :ref:`1D plotting section <ug_1dstd>`). To change the global property
69+
# cycler, pass a `~proplot.colors.DiscreteColormap` or cycle name
7070
# to :rcraw:`cycle` or pass the result of `~proplot.constructor.Cycle`
7171
# to :rcraw:`axes.prop_cycle` (see the :ref:`configuration guide <ug_config>`).
7272

@@ -107,23 +107,31 @@
107107
# Making color cycles
108108
# -------------------
109109
#
110-
# You can make new color cycles with the `~proplot.constructor.Cycle`
111-
# :ref:`constructor function <why_constructor>`. One great way to make cycles is by
112-
# sampling colormaps! Just pass the colormap name to `~proplot.constructor.Cycle`,
113-
# and optionally specify the number of samples you want to draw as the last
114-
# positional argument -- e.g. ``pplt.Cycle('Blues', 5)``. Calling e.g.
115-
# ``ax.plot(data, cycle='Blues')`` where ``data`` is a 2D array will automatically
116-
# use the same number of samples as the number of columns in the array.
117-
#
110+
# Proplot includes tools for merging color cycles, modifying existing color
111+
# cycles, making new color cycles, and saving color cycles for future use.
112+
# Most of these features can be accessed via the `~proplot.constructor.Cycle`
113+
# :ref:`constructor function <why_constructor>`. This command returns
114+
# `~cycler.Cycler` instances whose `color` properties are determined by the
115+
# positional arguments (see :ref:`below <ug_cycles_other>` for changing other
116+
# properties). Note that every `~proplot.axes.PlotAxes` command that accepts a
117+
# `cycle` keyword passes it through this function (see the :ref:`1D plotting
118+
# section <ug_apply_cycle>`).
119+
118120
# Positional arguments passed to `~proplot.constructor.Cycle` are interpreted
119-
# by the `~proplot.constructor.Colormap` constructor function, and the resulting
120-
# colormap is sampled at discrete values. To exclude near-white colors on the
121-
# end of a colormap, pass e.g. ``left=x`` to `~proplot.constructor.Cycle`, or
122-
# supply a plotting command with e.g. ``cycle_kw={'left': x}``. See
123-
# the :ref:`colormaps section <ug_cmaps>` for details.
121+
# by the `~proplot.constructor.Colormap` constructor function. If the result
122+
# is a `~proplot.colors.DiscreteColormap`, those colors are used for the resulting
123+
# `~cycler.Cycler`. If the result is a `~proplot.colors.ContinuousColormap`, the
124+
# colormap is sampled at `N` discrete values -- for example, ``pplt.Cycle('Blues', 5)``
125+
# selects 5 evenly-spaced values. When building color cycles on-the-fly, for example
126+
# with ``ax.plot(data, cycle='Blues')``, proplot automatically selects as many colors
127+
# as there are columns in the 2D array (i.e., if we are drawing 10 lines using an array
128+
# with 10 columns, proplot will select 10 evenly-spaced values from the colormap).
129+
# To exclude near-white colors on the end of a colormap, pass e.g. ``left=x``
130+
# to `~proplot.constructor.Cycle`, or supply a plotting command with e.g.
131+
# ``cycle_kw={'left': x}``. See the :ref:`colormaps section <ug_cmaps>` for details.
124132
#
125-
# In the below example, several cycles are constructed from scratch, and the
126-
# lines are referenced with colorbars and legends. Note that proplot permits
133+
# In the below example, several color cycles are constructed from scratch, and
134+
# the lines are referenced with colorbars and legends. Note that proplot permits
127135
# generating colorbars from :ref:`lists of artists <ug_colorbars>`.
128136

129137
# %%
@@ -155,10 +163,13 @@
155163
# Cycles of other properties
156164
# --------------------------
157165
#
158-
# `~proplot.constructor.Cycle` can also generate cyclers that change
159-
# properties other than color. Below, a single-color dash style cycler is
160-
# constructed and applied to the axes locally. To apply it globally, simply
161-
# use ``pplt.rc['axes.prop_cycle'] = cycle``.
166+
# `~proplot.constructor.Cycle` can generate `~cycler.Cycler` instances that
167+
# change `~proplot.axes.PlotAxes.line` and `~proplot.axes.PlotAxes.scatter`
168+
# properties other than `color`. In the below example, a single-color line
169+
# property cycler is constructed and applied to the axes locally using the
170+
# line properties `lw` and `dashes` (the aliases `linewidth` or `linewidths`
171+
# would also work). The resulting property cycle can be applied globally
172+
# using ``pplt.rc['axes.prop_cycle'] = cycle``.
162173

163174
# %%
164175
import proplot as pplt

0 commit comments

Comments
 (0)