Skip to content

Commit ffb90f7

Browse files
committed
More why proplot improvements
1 parent e1bd91f commit ffb90f7

File tree

1 file changed

+61
-54
lines changed

1 file changed

+61
-54
lines changed

docs/why.rst

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ There are also several useful new :ref:`colorbar <ug_cbars>` and
366366

367367
.. _why_plotting:
368368

369-
Improved plotting methods
370-
=========================
369+
Improved plotting commands
370+
==========================
371371

372372
.. rubric:: Limitation
373373

@@ -389,71 +389,78 @@ have this functionality built right into matplotlib's interface.
389389
.. rubric:: Solution
390390

391391
ProPlot adds various `seaborn`_, `xarray`_, and `pandas`_ features to the
392-
`~proplot.axes.Axes` plotting methods along with several additional features
392+
`~proplot.axes.Axes` plotting commands along with several additional features
393393
designed to make your life easier.
394394

395-
The following features are relevant for "1D" plotting methods like
395+
The following features are relevant for "1D" plotting commands like
396396
`~matplotlib.axes.Axes.plot` and `~matplotlib.axes.Axes.scatter`:
397397

398-
* The new `~proplot.axes.Axes.parametric` method draws
399-
:ref:`parametric lines <ug_parametric>`, where the parametric coordinate is
400-
denoted with colormap colors rather than text annotations.
401-
* The `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh` methods accept
402-
2D arrays and can :ref:`stack or group <ug_bar>` successive columns. Similarly,
403-
the new `~proplot.axes.Axes.area` and `~proplot.axes.Axes.areax` methods
404-
(aliases for `~matplotlib.axes.Axes.fill_between` and
405-
`~matplotlib.axes.Axes.fill_betweenx`) also accept 2D arrays
406-
and can :ref:`stack or overlay <ug_bar>` successive columns.
398+
* The `cycle` :ref:`keyword argument <ug_apply_cycle>` changes the property cycle
399+
on-the-fly. It is interpreted by the `~proplot.constructor.Cycle`
400+
:ref:`constructor function <why_constructor>`, allowing for flexible specification.
401+
* The `colorbar` and `legend` keywords draw
402+
:ref:`colorbars and legends on-the-fly <ug_cbars_axes>`. Note that colorbars can
403+
now be easily drawn from :ref:`lists of artists <ug_cbars>`.
404+
* The `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh` commands accept
405+
2D arrays and can :ref:`stack or group <ug_bar>` successive columns.
406+
The `~matplotlib.axes.Axes.fill_between` and `~matplotlib.axes.Axes.fill_betweenx`
407+
commands (also accessible via the shorthands `~proplot.axes.Axes.area` and
408+
`~proplot.axes.Axes.areax`) also accept 2D arrays and can
409+
:ref:`stack or overlay <ug_bar>` successive columns.
407410
* The `~matplotlib.axes.Axes.bar`, `~matplotlib.axes.Axes.barh`,
408411
`~matplotlib.axes.Axes.vlines`, `~matplotlib.axes.Axes.hlines`,
409-
`~proplot.axes.Axes.area`, and `~proplot.axes.Axes.areax` commands
410-
all accept a `negpos` keyword argument that can be used to assign
411-
"negative" and "positive" colors to different regions.
412-
* You can now :ref:`add error bars or error shading <ug_errorbars>`
413-
to `~matplotlib.axes.Axes.bar`, `~matplotlib.axes.Axes.barh`, and
414-
`~matplotlib.axes.Axes.plot` plots by passing keyword arguments to
415-
these functions. You do not have to work with the
416-
`~matplotlib.axes.Axes.errorbar` method separately.
417-
* All :ref:`1D plotting methods <ug_1dplots>` accept a
418-
`cycle` :ref:`keyword argument <ug_apply_cycle>`
419-
interpreted by `~proplot.constructor.Cycle`. They also accept
420-
`colorbar` and `legend` keywords for drawing
421-
:ref:`on-the-fly colorbars and legends <ug_cbars_axes>` at the specified location.
422-
423-
The following features are relevant for "2D" plotting methods like
412+
`~proplot.axes.Axes.fill_between`, and `~proplot.axes.Axes.fill_betweenx`
413+
commands accept a `negpos` keyword argument that assigns different
414+
colors to "negative" and "positive" regions.
415+
* The `~matplotlib.axes.Axes.plot`, `~matplotlib.axes.Axes.scatter`, and
416+
`~matplotlib.axes.Axes.bar` commands can draw :ref:`on-the-fly error bars and
417+
"shading" <ug_errorbars>` using a variety of keyword arguments. This is often
418+
more convenient than working with the `~matplotlib.axes.Axes.errorbar` command.
419+
* The new `~proplot.axes.Axes.plotx` and `~proplot.axes.Axes.scatterx` commands
420+
are just like `~proplot.axes.Axes.plot` and `~proplot.axes.Axes.scatter`, but
421+
single positional arguments are interpreted as *y* coordinates and multiple
422+
positional arguments are interpreted as (*y*, *x*) pairs.
423+
* The new `~proplot.axes.Axes.parametric` method can draw clean-looking
424+
:ref:`parametric lines <ug_parametric>` with the parametric coordinate
425+
denoted by colormap colors rather than text annotations.
426+
427+
The following features are relevant for "2D" plotting commands like
424428
`~matplotlib.axes.Axes.pcolor` and `~matplotlib.axes.Axes.contour`:
425429

426-
* The new `~proplot.axes.Axes.heatmap` method invokes
427-
`~matplotlib.axes.Axes.pcolormesh` and draws ticks at the center of each
428-
box. This is more convenient for things like covariance matrices.
429-
* Wherever colormaps are used, they can be divided into
430-
:ref:`discrete levels <ug_discrete>` using keyword arguments like `levels`
431-
-- similar to `~matplotlib.axes.Axes.contourf`. This is accomplished by applying
432-
`~proplot.colors.DiscreteNorm` as the default normalizer. This feature
433-
can be disabled by setting :rcraw:`image.discrete` to ``False``.
430+
* The `cmap` and `norm` :ref:`keyword arguments <ug_apply_cmap>` are interpreted
431+
by the `~proplot.constructor.Colormap` and `~proplot.constructor.Norm`
432+
:ref:`constructor functions <why_constructor>`, allowing for flexible specification.
433+
* The `colorbar` keyword draw :ref:`on-the-fly colorbars <ug_cbars_axes>`.
434+
Note that "inset" colorbar locations can also be used, analogous to
435+
"inset" legends.
436+
* The `~matplotlib.axes.Axes.contour`, `~matplotlib.axes.Axes.contourf`,
437+
`~matplotlib.axes.Axes.pcolormesh`, and `~matplotlib.axes.Axes.pcolor` commands
438+
all accept a `labels` keyword. This draws :ref:`contour and grid box labels
439+
<ug_labels>` on-the-fly. Labels are automatically colored black or white
440+
according to the luminance of the underlying filled contour or grid box color.
441+
* The `~proplot.colors.DiscreteNorm` normalizer is paired with most colormaps by
442+
default and can easily divide colormaps into distinct levels, similar to
443+
`~matplotlib.axes.Axes.contourf`. This can be disabled by setting
444+
:rcraw:`image.discrete` to ``False`` or passing ``discrete=False`` to plots.
434445
* The `~proplot.colors.DivergingNorm` normalizer is perfect for data with a
435446
:ref:`natural midpoint <ug_norm>` and offers both "fair" and "unfair" scaling.
436-
The new `~proplot.colors.LinearSegmentedNorm` normalizer can generate the
447+
The `~proplot.colors.LinearSegmentedNorm` normalizer can generate
437448
uneven color gradations useful for :ref:`unusually distributed <ug_norm>` data.
438-
* The `~matplotlib.axes.Axes.contour`, `~matplotlib.axes.Axes.contourf`,
439-
`~matplotlib.axes.Axes.pcolormesh`, and `~matplotlib.axes.Axes.pcolor` commands
440-
all accept a `labels` :ref:`keyword argument <ug_labels>`. This draws contour labels
441-
and grid box labels on-the-fly. Labels are colored black or white according to the
442-
luminance of the underlying filled contour or grid box color.
443-
* Matplotlib requires coordinate "centers" for contour plots and "edges" for
444-
pcolor plots. If you pass centers to pcolor, matplotlib treats them as
445-
edges, then silently trims one row/column of your data. ProPlot
446-
:ref:`changes this behavior <ug_2dstd>` so that your data is not trimmed.
447-
* ProPlot fixes an irritating issue with saved vector graphics where white
448-
lines appear between `filled contours
449+
* The new `~proplot.axes.Axes.heatmap` command invokes
450+
`~matplotlib.axes.Axes.pcolormesh` then by default applies an :ref:`equal axes apect ratio
451+
<https://matplotlib.org/stable/gallery/subplots_axes_and_figures/axis_equal_demo.html>`,
452+
adds ticks to the center of each gridbox, and disables minor ticks and gridlines.
453+
This can be convenient for things like covariance matrices.
454+
* ProPlot transforms coordinate edges into "centers" when passed to commands
455+
like `~matplotlib.axes.Axes.contour`, and transforms coordinate centers to "edges"
456+
when passed to commands like `~matplotlib.axes.Axes.pcolor`. In matplotlib, `contour`
457+
requires centers, and `pcolor` truncates the data when it receives centers.
458+
* ProPlot fixes an irritating issue where saved vector graphics appear to have
459+
thin white lines between `filled contours
449460
<https://stackoverflow.com/q/8263769/4970632>`__, `pcolor patches
450461
<https://stackoverflow.com/q/27092991/4970632>`__, and `colorbar patches
451-
<https://stackoverflow.com/q/15003353/4970632>`__.
452-
* All :ref:`2D plotting methods <ug_2dplots>` methods accept
453-
`cmap` and `norm` :ref:`keyword arguments <ug_apply_cmap>`
454-
interpreted by `~proplot.constructor.Colormap` and
455-
`~proplot.constructor.Norm`. They also accept a `colorbar` keyword for drawing
456-
:ref:`on-the-fly colorbars <ug_cbars_axes>` at the specified location.
462+
<https://stackoverflow.com/q/15003353/4970632>`__. In matplotlib, these
463+
corrections must be applied manually.
457464

458465
..
459466
ProPlot also provides *constistent behavior* when switching between

0 commit comments

Comments
 (0)