|
230 | 230 | # You can also create on-the-fly "qualitative" `~proplot.colors.DiscreteColormap`\ s |
231 | 231 | # by passing lists of colors to the keyword `c`, `color`, or `colors`. |
232 | 232 | # |
233 | | -# To apply the default sequential, diverging, cyclic, or qualitative colormap to |
234 | | -# a plot, pass ``sequential=True``, ``diverging=True``, ``cyclic=True``, or |
235 | | -# ``qualitative=True`` to any plotting command. The default colormaps of each |
236 | | -# type are :rc:`cmap.sequential`, :rc:`cmap.diverging`, :rc:`cmap.cyclic`, and |
| 233 | +# To apply the default :ref:`sequential, diverging, cyclic <ug_cmaps_included>`, |
| 234 | +# or :ref:`qualitative <ug_cycles_included>` colormap, pass ``sequential=True``, |
| 235 | +# ``diverging=True``, ``cyclic=True``, or ``qualitative=True`` to any plotting |
| 236 | +# command. The default colormaps of each type are specified with the proplot |
| 237 | +# settings :rc:`cmap.sequential`, :rc:`cmap.diverging`, :rc:`cmap.cyclic`, and |
237 | 238 | # :rc:`cmap.qualitative`. Unless otherwise specified, the sequential colormap |
238 | 239 | # is used with the default (linear) normalizer when data is strictly positive |
239 | 240 | # or negative, and the diverging colormap is used when the data limits or |
|
251 | 252 | # Custom defaults of each type |
252 | 253 | pplt.rc['cmap.sequential'] = 'PuBuGn' |
253 | 254 | pplt.rc['cmap.diverging'] = 'PiYG' |
254 | | -pplt.rc['cmap.cyclic'] = 'corkO' |
| 255 | +pplt.rc['cmap.cyclic'] = 'bamO' |
255 | 256 | pplt.rc['cmap.qualitative'] = 'flatui' |
256 | 257 |
|
257 | 258 | # Make plots. Note the default behavior is sequential=True or diverging=True |
|
303 | 304 | # |
304 | 305 | # Changing the normalizer |
305 | 306 | # ----------------------- |
306 | | - |
307 | | -# In matplotlib, data values are translated into |
308 | | -# colormap colors using so-called `colormap "normalizers" |
309 | | -# <https://matplotlib.org/stable/tutorials/colors/colormapnorms.html>`__. |
310 | | -# A normalizer can be selected from its "registered" name using the |
| 307 | +# |
| 308 | +# Matplotlib `colormap "normalizers" |
| 309 | +# <https://matplotlib.org/stable/tutorials/colors/colormapnorms.html>`__ |
| 310 | +# translate raw data values into normalized colormap indices. In proplot, |
| 311 | +# you can select the normalizer from its "registered" name using the |
311 | 312 | # `~proplot.constructor.Norm` :ref:`constructor function <why_constructor>`. You |
312 | 313 | # can also build a normalizer on-the-fly using the `norm` and `norm_kw` keywords, |
313 | | -# again available with most `~proplot.axes.PlotAxes` 2D plot commands. |
| 314 | +# available with most `~proplot.axes.PlotAxes` 2D plot commands. |
314 | 315 | # If you want to work with the normalizer classes directly, they are available in |
315 | 316 | # the top-level namespace (e.g., ``norm=pplt.LogNorm(...)`` is allowed). To |
316 | 317 | # explicitly set the normalization range, you can pass the usual `vmin` and `vmax` |
317 | | -# keywords to the plotting command. See the :ref:`next section <ug_discrete>` for |
318 | | -# more details on colormap normalization. |
| 318 | +# keywords to the plotting command. See :ref:`below <ug_discrete>` for more |
| 319 | +# details on colormap normalization in proplot. |
319 | 320 |
|
320 | 321 | # %% |
321 | 322 | import proplot as pplt |
|
343 | 344 | # Special normalizers |
344 | 345 | # ------------------- |
345 | 346 | # |
346 | | -# Proplot includes two new "continuous" normalizers. `~proplot.colors.SegmentedNorm` |
347 | | -# provides even color gradations with respect to *index* for an arbitrary |
348 | | -# monotonically increasing or decreasing list of levels. This is automatically |
349 | | -# applied if you pass unevenly spaced `levels` to a plotting command, or it can be |
350 | | -# manually applied using e.g. ``norm='segmented'``. This can be useful for datasets |
351 | | -# with unusual statistical distributions or spanning a wide range of magnitudes. |
| 347 | +# Proplot includes two new :ref:`"continuous" normalizers <ug_norm>`. |
| 348 | +# `~proplot.colors.SegmentedNorm` provides even color gradations with respect to |
| 349 | +# index for an arbitrary monotonically increasing or decreasing list of levels. This is |
| 350 | +# automatically applied if you pass unevenly spaced `levels` to a plotting command, or |
| 351 | +# it can be manually applied using e.g. ``norm='segmented'``. This can be useful for |
| 352 | +# datasets with unusual statistical distributions or spanning many orders of magnitudes. |
352 | 353 | # |
353 | | -# The `~proplot.colors.DivergingNorm` normalizer ensures the colormap midpoint lies |
354 | | -# on some *central* data value (usually 0), even if `vmin`, `vmax`, or `levels` |
| 354 | +# The `~proplot.colors.DivergingNorm` normalizer ensures that colormap midpoints lie |
| 355 | +# on some central data value (usually ``0``), even if `vmin`, `vmax`, or `levels` |
355 | 356 | # are asymmetric with respect to the central value. This is automatically applied |
356 | 357 | # if your data contains negative and positive values (see :ref:`below <ug_autonorm>`), |
357 | 358 | # or it can be manually applied using e.g. ``diverging=True`` or ``norm='diverging'``. |
|
365 | 366 | # should be used with care, as it may lead you to misinterpret your data. |
366 | 367 | # |
367 | 368 | # The below examples demonstrate how these normalizers |
368 | | -# affect the interpretation of colormap plots. |
| 369 | +# affect the interpretation of different datasets. |
369 | 370 |
|
370 | 371 | # %% |
371 | 372 | import proplot as pplt |
|
421 | 422 | # --------------- |
422 | 423 | # |
423 | 424 | # By default, proplot uses `~proplot.colors.DiscreteNorm` to "discretize" |
424 | | -# the possible colormap colors for contour and pseudocolor plotting commands, |
425 | | -# including `~proplot.axes.PlotAxes.contourf` and `~proplot.axes.PlotAxes.pcolor`. |
| 425 | +# the possible colormap colors for contour and pseudocolor plotting commands |
| 426 | +# (e.g., `~proplot.axes.PlotAxes.contourf`, `~proplot.axes.PlotAxes.pcolor`). |
426 | 427 | # This is analogous to `matplotlib.colors.BoundaryNorm`, except |
427 | 428 | # `~proplot.colors.DiscreteNorm` can be paired with arbitrary |
428 | | -# continuous normalizers like `~matplotlib.colors.LogNorm`, |
429 | | -# `~proplot.colors.DivergingNorm`, or `~proplot.colors.SegmentedNorm`. |
| 429 | +# continuous normalizers specified by `norm` (see :ref:`above <ug_norm>`). |
430 | 430 | # Discrete color levels can help readers discern exact numeric values and |
431 | 431 | # tend to reveal qualitative structure in the data. `~proplot.colors.DiscreteNorm` |
432 | 432 | # also repairs the colormap end-colors by ensuring the following conditions are met: |
433 | 433 | # |
434 | | -# #. All colormaps always span the *entire color range*, |
435 | | -# independent of the `extend` setting. |
| 434 | +# #. All colormaps always span the *entire color range* |
| 435 | +# regardless of the `extend` parameter. |
436 | 436 | # #. Cyclic colormaps always have *distinct color levels* |
437 | 437 | # on either end of the colorbar. |
438 | 438 | # |
|
445 | 445 | # keywords (or to the `N` keyword) to automatically generate approximately that many |
446 | 446 | # level edges or centers at "nice" intervals. The algorithm used to generate levels |
447 | 447 | # is similar to matplotlib's algorithm for selecting contour levels. The default |
448 | | -# number of levels is controlled by :rcraw:`cmap.levels`, and the algorithm is |
449 | | -# constrained by the keywords `vmin`, `vmax`, `locator`, and `locator_kw` -- for |
| 448 | +# number of levels is controlled by :rcraw:`cmap.levels`, and the level selection |
| 449 | +# is constrainted by the keywords `vmin`, `vmax`, `locator`, and `locator_kw` -- for |
450 | 450 | # example, ``vmin=100`` ensures the minimum level is greater than or equal to ``100``, |
451 | | -# and ``locator=5`` ensures a level step size of 5 (see the :ref:`axis locators |
452 | | -# <ug_locators>` section for details). You can also use the keywords `positive`, |
453 | | -# `negative`, and `symmetric` to ensure that your levels are strictly positive, |
454 | | -# strictly negative, or symmetric about zero, or use the `nozero` keyword to remove |
| 451 | +# and ``locator=5`` ensures a level step size of 5 (see :ref:`this section |
| 452 | +# <ug_locators>` for more on locators). You can also use the keywords `negative`, |
| 453 | +# `positive`, or `symmetric` to ensure that your levels are strictly negative, |
| 454 | +# positive, or symmetric about zero, or use the `nozero` keyword to remove |
455 | 455 | # the zero level (useful for single-color `~proplot.axes.PlotAxes.contour` plots). |
456 | 456 |
|
457 | 457 | # %% |
|
529 | 529 | # |
530 | 530 | # Additionally, `similar to xarray |
531 | 531 | # <http://xarray.pydata.org/en/stable/user-guide/plotting.html#colormaps>`__, |
532 | | -# proplot can automatically detect "diverging" datasets. That is, the |
533 | | -# `~proplot.axes.PlotAxes` 2D plot commands will by default apply the diverging colormap |
534 | | -# :rc:`cmap.diverging` (rather than the default colormap :rc:`cmap.sequential`) and |
535 | | -# the diverging normalizer `~proplot.colors.DivergingNorm` (rather than the |
536 | | -# linear normalizer `~matplotlib.colors.Normalize` -- see :ref:`above <ug_norm>`) |
537 | | -# if the following conditions are met: |
| 532 | +# proplot can automatically detect "diverging" datasets. By default, the |
| 533 | +# `~proplot.axes.PlotAxes` 2D plot commands will apply the diverging colormap |
| 534 | +# :rc:`cmap.diverging` (rather than :rc:`cmap.sequential`) and the diverging |
| 535 | +# normalizer `~proplot.colors.DivergingNorm` (rather than `~matplotlib.colors.Normalize` |
| 536 | +# -- see :ref:`above <ug_norm>`) if the following conditions are met: |
538 | 537 | # |
539 | 538 | # #. If discrete levels are enabled (see :ref:`above <ug_discrete>`) and the |
540 | 539 | # level list includes at least 2 negative and 2 positive values. |
|
0 commit comments