Skip to content

Commit 64a488a

Browse files
committed
Update docs and order of appearence in API tables
1 parent 89d6f5b commit 64a488a

File tree

13 files changed

+281
-209
lines changed

13 files changed

+281
-209
lines changed

docs/1dplots.py

Lines changed: 135 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,24 @@
281281
# The `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh` methods
282282
# are wrapped by `~proplot.axes.bar_extras`,
283283
# `~proplot.axes.apply_cycle`, and `~proplot.axes.standardize_1d`.
284+
# This means that `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh` employ
285+
# default *x* or *y* coordinates if you failed to provide them explicitly.
284286
# You can now *group* or *stack* columns of data by passing 2D arrays to
285287
# `~matplotlib.axes.Axes.bar` or `~matplotlib.axes.Axes.barh`, just like in
286-
# `pandas`_, or use different colors for negative and positive bars by
287-
# passing ``negpos=True``. Also, `~matplotlib.axes.Axes.bar` and
288-
# `~matplotlib.axes.Axes.barh` now employ "default" *x* coordinates if you
289-
# failed to provide them explicitly.
288+
# `pandas`_. You can also use different colors for "negative" and "positive"
289+
# bars by passing ``negpos=True`` (the default colors are :rc:`negcolor`
290+
# and :rc:`poscolor`).
290291
#
291-
# To make filled "area" plots, use the new `~proplot.axes.Axes.area` and
292-
# `~proplot.axes.Axes.areax` methods. These are alises for
293-
# `~matplotlib.axes.Axes.fill_between` and
294-
# `~matplotlib.axes.Axes.fill_betweenx`, which are wrapped by
295-
# `~proplot.axes.fill_between_extras` and
296-
# `~proplot.axes.fill_betweenx_extras`. You can now *stack* or *overlay*
297-
# columns of data by passing 2D arrays to `~proplot.axes.Axes.area` and
298-
# `~proplot.axes.Axes.areax`, just like in `pandas`_. You can also now draw
299-
# area plots that change color when the fill boundaries cross each other by
300-
# passing ``negpos=True`` to `~matplotlib.axes.Axes.fill_between`. The most
301-
# common use case for this is highlighting negative and positive areas with
302-
# different colors, as shown below.
292+
# The `~matplotlib.axes.Axes.fill_between` and `~matplotlib.axes.Axes.fill_betweenx`
293+
# commands are wrapped by `~proplot.axes.fill_between_extras` and
294+
# `~proplot.axes.fill_betweenx_extras`. They also now have the optional shorthands
295+
# `~proplot.axes.Axes.area` and `~proplot.axes.Axes.areax`.
296+
# You can now *stack* or *overlay* columns of data by passing 2D arrays to
297+
# to these commands, just like in `pandas`_. You can also draw area plots that
298+
# change color when the fill boundaries cross each other by passing ``negpos=True``
299+
# (the default colors are :rc:`negcolor` and :rc:`poscolor`). The most common
300+
# use case for this is highlighting *negative* and *positive* areas with different
301+
# colors, as shown below.
303302

304303
# %%
305304
import proplot as plot
@@ -400,12 +399,14 @@
400399
# --------------------------
401400
#
402401
# The `~matplotlib.axes.Axes.boxplot` and `~matplotlib.axes.Axes.violinplot`
403-
# methods are now wrapped with `~proplot.axes.boxplot_extras`,
402+
# commands are wrapped by `~proplot.axes.boxplot_extras`,
404403
# `~proplot.axes.violinplot_extras`, `~proplot.axes.apply_cycle`,
405-
# and `~proplot.axes.standardize_1d`. These wrappers add some useful
406-
# options and apply aesthetically pleasing default settings. They also
407-
# automatically apply axis labels based on the `~pandas.DataFrame` column
408-
# labels or the input *x* coordinate labels.
404+
# and `~proplot.axes.standardize_1d`. They also now have the optional shorthands
405+
# `~proplot.axes.Axes.boxes` and `~proplot.axes.Axes.violins`. The wrappers
406+
# apply aesthetically pleasing default settings and permit configuration using
407+
# keyword arguments like ``color``, ``boxcolor``, and ``fillcolor``. They also
408+
# automatically apply axis labels based on the `~pandas.DataFrame` or
409+
# `~xarray.DataArray` column labels or the input *x* coordinate labels.
409410

410411
# %%
411412
import proplot as plot
@@ -443,90 +444,96 @@
443444
ax = axs[2]
444445
data = state.rand(100, 7)
445446
colors = plot.Colors('pastel2') # list of colors from the cycle
446-
ax.boxes(data, fillcolor=colors)
447+
ax.boxplot(data, fillcolor=colors, orientation='horizontal')
447448
ax.format(title='Multiple colors', titleloc='uc', ymargin=0.15)
448449

449450

450451
# %% [raw] raw_mimetype="text/restructuredtext"
451-
# .. _ug_parametric:
452+
# .. _ug_lines:
452453
#
453-
# Parametric plots
454-
# ----------------
454+
# Line plots
455+
# ----------
455456
#
456-
# To make "parametric" plots, use the new `~proplot.axes.Axes.parametric`
457-
# method. Parametric plots are
458-
# `~matplotlib.collections.LineCollection`\ s that map individual line
459-
# segments to individual colors, where each segment represents a "parametric"
460-
# coordinate (e.g., time). The parametric coordinates are specified with the
461-
# `values` keyword argument. See `~proplot.axes.Axes.parametric` for details.
462-
# As shown below, it is also easy to build colorbars from the
463-
# `~matplotlib.collections.LineCollection` returned by
464-
# `~proplot.axes.Axes.parametric`.
457+
# The `~matplotlib.axes.Axes.plot` command is wrapped by
458+
# `~proplot.axes.apply_cycle` and `~proplot.axes.standardize_1d`.
459+
# But in general, its behavior is the same -- ProPlot simply tries to expand
460+
# the flexibility of this command to the rest of the 1D plotting commands.
461+
# The new `~proplot.axes.Axes.plotx` command can be used just like
462+
# `~matplotlib.axes.Axes.plotx`, except a single argument is interpreted
463+
# as *x* coordinates (with default *y* coordinates inferred from the data),
464+
# and multiple arguments are interpreted as *y* and *x* coordinates (in that order).
465+
# This is analogous to `~matplotlib.axes.Axes.barh` and
466+
# `~matplotlib.axes.Axes.fill_betweenx`.
467+
#
468+
# As with the other 1D plotting commands, `~matplotlib.axes.Axes.step`,
469+
# `~matplotlib.axes.Axes.hlines`, `~matplotlib.axes.Axes.vlines`, and
470+
# `~matplotlib.axes.Axes.stem` are wrapped by `~proplot.axes.standardize_1d`.
471+
# `~proplot.axes.Axes.step` now use the property cycle, just like
472+
# `~matplotlib.axes.Axes.plot`. `~matplotlib.axes.Axes.vlines` and
473+
# `~matplotlib.axes.Axes.hlines` are also wrapped by `~proplot.axes.vlines_extras`
474+
# and `~proplot.axes.hlines_extras`, which can use
475+
# different colors for "negative" and "positive" lines using ``negpos=True``
476+
# (the default colors are :rc:`negcolor` and :rc:`poscolor`).
465477

466478
# %%
467479
import proplot as plot
468480
import numpy as np
469-
fig, axs = plot.subplots(
470-
share=0, ncols=2, wratios=(2, 1),
471-
figwidth='16cm', refaspect=(2, 1)
472-
)
473-
axs.format(suptitle='Parametric plots demo')
474-
cmap = 'IceFire'
475-
476-
# Sample data
477481
state = np.random.RandomState(51423)
478-
N = 50
479-
x = (state.rand(N) - 0.52).cumsum()
480-
y = state.rand(N)
481-
c = np.linspace(-N / 2, N / 2, N) # color values
482+
fig, axs = plot.subplots(ncols=2, nrows=2, share=0)
483+
axs.format(suptitle='Line plots demo', xlabel='xlabel', ylabel='ylabel')
482484

483-
# Parametric line with smooth gradations
485+
# Step
484486
ax = axs[0]
485-
m = ax.parametric(
486-
x, y, c, cmap=cmap, lw=7, interp=5, capstyle='round', joinstyle='round'
487-
)
488-
ax.format(xlabel='xlabel', ylabel='ylabel', title='Line with smooth gradations')
489-
ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)
490-
491-
# Sample data
492-
N = 12
493-
radii = np.linspace(1, 0.2, N + 1)
494-
angles = np.linspace(0, 4 * np.pi, N + 1)
495-
x = radii * np.cos(1.4 * angles)
496-
y = radii * np.sin(1.4 * angles)
497-
c = np.linspace(-N / 2, N / 2, N + 1)
487+
data = state.rand(20, 4).cumsum(axis=1).cumsum(axis=0)
488+
cycle = ('blue7', 'gray5', 'red7', 'gray5')
489+
ax.step(data, cycle=cycle, labels=list('ABCD'), legend='ul', legend_kw={'ncol': 2})
490+
ax.format(title='Step plot')
498491

499-
# Parametric line with stepped gradations
492+
# Stems
500493
ax = axs[1]
501-
m = ax.parametric(x, y, c, cmap=cmap, lw=15)
502-
ax.format(
503-
xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',
504-
xlabel='cosine angle', ylabel='sine angle'
505-
)
506-
ax.colorbar(m, loc='b', maxn=10, label='parametric coordinate')
494+
data = state.rand(20)
495+
ax.stem(data, linefmt='k-')
496+
ax.format(title='Stem plot')
507497

498+
# Vertical lines
499+
gray = 'gray7'
500+
data = state.rand(20) - 0.5
501+
ax = axs[2]
502+
ax.area(data, color=gray, alpha=0.2)
503+
ax.vlines(data, negpos=True, linewidth=2)
504+
ax.format(title='Vertical lines')
505+
506+
# Horizontal lines
507+
ax = axs[3]
508+
ax.areax(data, color=gray, alpha=0.2)
509+
ax.hlines(data, negpos=True, linewidth=2)
510+
ax.format(title='Horizontal lines')
508511

509512
# %% [raw] raw_mimetype="text/restructuredtext"
510513
# .. _ug_scatter:
511514
#
512-
# Other plotting methods
513-
# ----------------------
515+
# Scatter plots
516+
# -------------
514517
#
515-
# The `~matplotlib.axes.Axes.scatter` method is now wrapped by
518+
# The `~matplotlib.axes.Axes.scatter` command is wrapped by
516519
# `~proplot.axes.scatter_extras`, `~proplot.axes.apply_cycle`, and
517520
# `~proplot.axes.standardize_1d`. This means that
518-
# `~matplotlib.axes.Axes.scatter` now accepts 2D arrays, just like
519-
# `~matplotlib.axes.Axes.plot`. Also, successive calls to
520-
# `~matplotlib.axes.Axes.scatter` now use the property cycler properties
521-
# (e.g., `color`, `marker`, and `markersize`), and
522-
# `~matplotlib.axes.Axes.scatter` now optionally accepts keywords that look
523-
# like `~matplotlib.axes.Axes.plot` keywords (e.g., `color` instead of `c` and
524-
# `markersize` instead of `s`).
521+
# `~matplotlib.axes.Axes.scatter` now accepts 2D *y* coordinates and permits
522+
# omitting *x* coordinates, just like `~matplotlib.axes.Axes.plot`.
523+
# `~matplotlib.axes.Axes.scatter` now also accepts keywords that look like
524+
# `~matplotlib.axes.Axes.plot` keywords (e.g., `color` instead of `c` and
525+
# `markersize` instead of `s`). This way, `~matplotlib.axes.Axes.scatter` can
526+
# optionally be used simply to "plot markers, not lines" without changing the
527+
# input arguments relative to `~matplotlib.axes.Axes.plot`.
525528
#
526-
# ProPlot also supports property cycling for `~proplot.axes.Axes.step` plots
527-
# and wraps the `~matplotlib.axes.Axes.vlines` and `~matplotlib.axes.Axes.hlines`
528-
# methods with `~proplot.axes.vlines_extras` and `~proplot.axes.hlines_extras`,
529-
# which adds the ability to use different colors for "negative" and "positive" lines.
529+
# Just like `~matplotlib.axes.Axes.plot`, the property cycle is used
530+
# with `~matplotlib.axes.Axes.scatter` plots by default. It can be changed
531+
# using the `cycle` keyword argument, and it can include properties like `marker`
532+
# and `markersize`. The colormap `cmap` and normalizer `norm` used with the
533+
# optional `c` color array are now passed through the `~proplot.constructor.Colormap`
534+
# and `~proplot.constructor.Norm` constructor functions, and the the `s` marker
535+
# size array can now be conveniently scaled using the arguments `smin` and `smax`
536+
# (analogous to `vmin` and `vmax` used for colors).
530537

531538
# %%
532539
import proplot as plot
@@ -562,36 +569,58 @@
562569
)
563570
axs.format(xlabel='xlabel', ylabel='ylabel')
564571

572+
# %% [raw] raw_mimetype="text/restructuredtext"
573+
# .. _ug_parametric:
574+
#
575+
# Parametric plots
576+
# ----------------
577+
#
578+
# To make "parametric" plots, use the new `~proplot.axes.Axes.parametric`
579+
# command. Parametric plots are `~matplotlib.collections.LineCollection`\ s that
580+
# map individual line segments to individual colors, where each segment represents a
581+
# "parametric" coordinate (e.g., time). The parametric coordinates are specified with
582+
# the `values` keyword argument. See `~proplot.axes.Axes.parametric` for details. As
583+
# shown below, it is also easy to build colorbars from the
584+
# `~matplotlib.collections.LineCollection` returned by `~proplot.axes.Axes.parametric`.
585+
565586
# %%
566587
import proplot as plot
567588
import numpy as np
589+
fig, axs = plot.subplots(
590+
share=0, ncols=2, wratios=(2, 1),
591+
figwidth='16cm', refaspect=(2, 1)
592+
)
593+
axs.format(suptitle='Parametric plots demo')
594+
cmap = 'IceFire'
595+
596+
# Sample data
568597
state = np.random.RandomState(51423)
569-
fig, axs = plot.subplots(ncols=2, nrows=2, share=0)
570-
axs.format(suptitle='Line plots demo', xlabel='xlabel', ylabel='ylabel')
598+
N = 50
599+
x = (state.rand(N) - 0.52).cumsum()
600+
y = state.rand(N)
601+
c = np.linspace(-N / 2, N / 2, N) # color values
571602

572-
# Step
603+
# Parametric line with smooth gradations
573604
ax = axs[0]
574-
data = state.rand(20, 4).cumsum(axis=1).cumsum(axis=0)
575-
cycle = ('blue7', 'gray5', 'red7', 'gray5')
576-
ax.step(data, cycle=cycle, labels=list('ABCD'), legend='ul', legend_kw={'ncol': 2})
577-
ax.format(title='Step plot')
578-
579-
# Stems
580-
ax = axs[1]
581-
data = state.rand(20)
582-
ax.stem(data, linefmt='k-')
583-
ax.format(title='Stem plot')
605+
m = ax.parametric(
606+
x, y, c, cmap=cmap, lw=7, interp=5, capstyle='round', joinstyle='round'
607+
)
608+
ax.format(xlabel='xlabel', ylabel='ylabel', title='Line with smooth gradations')
609+
ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)
584610

585-
# Vertical lines
586-
gray = 'gray7'
587-
data = state.rand(20) - 0.5
588-
ax = axs[2]
589-
ax.area(data, color=gray, alpha=0.2)
590-
ax.vlines(data, negpos=True, linewidth=2)
591-
ax.format(title='Vertical lines')
611+
# Sample data
612+
N = 12
613+
radii = np.linspace(1, 0.2, N + 1)
614+
angles = np.linspace(0, 4 * np.pi, N + 1)
615+
x = radii * np.cos(1.4 * angles)
616+
y = radii * np.sin(1.4 * angles)
617+
c = np.linspace(-N / 2, N / 2, N + 1)
592618

593-
# Horizontal lines
594-
ax = axs[3]
595-
ax.areax(data, color=gray, alpha=0.2)
596-
ax.hlines(data, negpos=True, linewidth=2)
597-
ax.format(title='Horizontal lines')
619+
# Parametric line with stepped gradations
620+
ax = axs[1]
621+
m = ax.parametric(x, y, c, cmap=cmap, lw=15)
622+
ax.format(
623+
xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',
624+
xlabel='cosine angle', ylabel='sine angle'
625+
)
626+
ax.colorbar(m, loc='b', maxn=10, label='parametric coordinate')

docs/_static/custom.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,14 @@
7777
--accent-bg-color: #505050;
7878
}
7979

80-
/* Font families from modern pydata theme */
81-
/* Github fonts: */
82-
/* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; */
83-
/* Pandas fonts: */
84-
/* -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; */
85-
/* SFMono-Regular, Menlo, Consolas, Monaco, "Liberation Mono", "Lucida Console", monospace; */
80+
/* Pydata theme font families */
81+
/* Github: font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; */
82+
/* Pandas: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; */
8683
body, h1, h2, h3, h4, h5, h6, .rst-content .toctree-wrapper p.caption{
8784
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
8885
}
8986

90-
87+
/* Readjust font sizes */
9188
/* Keep bold headers but slightly larger than RTD and smaller than pydata */
9289
.rst-content div[class^='highlight'] pre,
9390
.rst-content pre.literal-block,

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
API reference
33
=============
44

5+
Comprehensive documentation of ProPlot functions and classes. Since all of
6+
these objects are imported into the top-level namespace, you can read the
7+
documentation within python sessions using ``help(plot.<function_or_class>)``.
8+
59
Top-level functions
610
===================
711

docs/basics.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,32 @@
4949
# %% [raw] raw_mimetype="text/restructuredtext"
5050
# .. note::
5151
#
52-
# ProPlot figure backgrounds are only gray when displayed by the
53-
# `matplotlib backend <https://matplotlib.org/faq/usage_faq#what-is-a-backend>`__
54-
# -- the default background color is white when the figure is saved. This is done
55-
# by setting :rcraw:`figure.facecolor` to gray, in order to improve contrast
56-
# when working with figures.
57-
#
58-
# ProPlot also changes the default :rcraw:`savefig.format` from PNG to PDF for the
59-
# following reasons:
52+
# ProPlot changes the default :rcraw:`figure.facecolor` so that the figure
53+
# backgrounds shown by the `matplotlib backend\
54+
# <https://matplotlib.org/faq/usage_faq#what-is-a-backend>`__ are gray (the
55+
# :rcraw:`savefig.facecolor` applied to saved figures is still white). This can be
56+
# helpful when designing figures. ProPlot also controls the appearence of figures
57+
# in Jupyter notebooks using the new :rcraw:`inlinefmt` setting, which is passed
58+
# to `~proplot.config.config_inline_backend` on import. This imposes a
59+
# higher-quality default `"inline" format\
60+
# <https://ipython.readthedocs.io/en/stable/interactive/plotting.html>`__
61+
# and disables the backend-specific settings ``InlineBackend.rc`` and
62+
# ``InlineBackend.print_figure_kwargs``, ensuring that the figures you save
63+
# look identical to the figures displayed by the backend.
64+
#
65+
# ProPlot also changes the default :rcraw:`savefig.format` from PNG to
66+
# PDF for the following reasons:
6067
#
6168
# #. Vector graphic formats are infinitely scalable.
6269
# #. Vector graphic formats are preferred by academic journals.
63-
# #. Most academic journals accept PDF figures alongside the traditional
64-
# `EPS <https://en.wikipedia.org/wiki/Encapsulated_PostScript>`__ format.
65-
# #. The EPS format does not support transparent graphic elements.
66-
#
67-
# In case you *do* need raster graphics, ProPlot sets the default
68-
# :rcraw:`savefig.dpi` to 1000 dots per inch, which is
69-
# `recommended by most journals <https://www.pnas.org/page/authors/format>`__
70+
# #. Nearly all academic journals accept figures in the PDF format alongside
71+
# the `EPS <https://en.wikipedia.org/wiki/Encapsulated_PostScript>`__ format.
72+
# #. The EPS format is outdated and does not support transparent graphic
73+
# elements.
74+
#
75+
# In case you *do* need a raster format like PNG, ProPlot increases the
76+
# default :rcraw:`savefig.dpi` to 1000 dots per inch, which is
77+
# `recommended <https://www.pnas.org/page/authors/format>`__ by most journals
7078
# as the minimum resolution for rasterized figures containing lines and text.
7179
# See the :ref:`configuration section <ug_proplotrc>` for how to change
7280
# these settings.
@@ -77,8 +85,8 @@
7785
# column share the same axis limits, scales, ticks, and labels. This is often
7886
# convenient, but may be annoying for some users. To keep this feature turned off,
7987
# simply :ref:`change the default settings <ug_rc>` with e.g.
80-
# ``plot.rc.update(share=False, span=False)``. See :ref:`this section <ug_share>`
81-
# for details.
88+
# ``plot.rc.update(share=False, span=False)``. See the
89+
# :ref:`axis-sharing section <ug_share>` for details.
8290

8391
# %%
8492
# Sample data

0 commit comments

Comments
 (0)