Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cce4441

Browse files
committed
mention matlab origin, add cyclic description, describe ColorBrewer schemes, discourage use of qualitative and redundant schemes, change some details based on luminance plots
1 parent 11590e6 commit cce4441

1 file changed

Lines changed: 118 additions & 84 deletions

File tree

lib/matplotlib/pyplot.py

Lines changed: 118 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,64 +1654,71 @@ def colormaps():
16541654
16551655
imshow(X, cmap=cm.hot)
16561656
1657-
or post-hoc using the :func:`set_cmap` function::
1657+
or using the :func:`set_cmap` function::
16581658
16591659
imshow(X)
16601660
pyplot.set_cmap('hot')
16611661
pyplot.set_cmap('jet')
16621662
1663-
In interactive mode, this will update the colormap allowing you to
1664-
see which one works best for your data. Additionally, for the "base"
1665-
colormaps below, you can set the colormap using the corresponding pylab
1666-
shortcut interface function::
1667-
1668-
imshow(X)
1669-
hot()
1670-
jet()
1671-
1663+
In interactive mode, :func:`set_cmap` will update the colormap post-hoc,
1664+
allowing you to see which one works best for your data.
1665+
16721666
All built-in colormaps can be reversed by appending ``_r``: For instance,
16731667
``gray_r`` is the reverse of ``gray``.
16741668
1675-
There are 3 common color schemes used in visualization:
1676-
1677-
1. Sequential schemes, for unipolar data that progresses from low to high
1678-
2. Diverging schemes, for bipolar data that emphasizes positive or
1679-
negative deviations from a central value
1680-
3. Qualitative schemes, for categorical data where color doesn't have a
1681-
relationship to magnitude
1682-
1683-
The base colormaps are:
1684-
1669+
There are several common color schemes used in visualization:
1670+
1671+
Sequential schemes
1672+
for unipolar data that progresses from low to high
1673+
Diverging schemes
1674+
for bipolar data that emphasizes positive or negative deviations from a
1675+
central value
1676+
Cyclic schemes
1677+
meant for plotting values that wrap around at the
1678+
endpoints, such as phase angle, wind direction, or time of day
1679+
Qualitative schemes
1680+
for nominal data that has no inherent ordering, where color is used
1681+
only to distinguish categories
1682+
1683+
The base colormaps are (with the exception of `spectral`) derived from
1684+
those of the same name provided with Matlab:
1685+
16851686
========= =======================================================
16861687
Colormap Description
16871688
========= =======================================================
1688-
autumn sequential increasing shades of red-orange-yellow
1689-
bone sequential black-white color map with a tinge of blue,
1690-
to emulate X-ray film
1691-
cool sequential decreasing shades of cyan-magenta
1689+
autumn sequential linearly-increasing shades of red-orange-yellow
1690+
bone sequential increasing black-white color map with
1691+
a tinge of blue, to emulate X-ray film
1692+
cool linearly-decreasing shades of cyan-magenta
16921693
copper sequential increasing shades of black-copper
1693-
flag repeating red-white-blue-black pattern
1694-
gray simple sequential linearly-increasing black-to-white
1694+
flag repetitive red-white-blue-black pattern (not cyclic at
1695+
endpoints)
1696+
gray sequential linearly-increasing black-to-white
16951697
grayscale
16961698
hot sequential black-red-yellow-white, to emulate blackbody
16971699
radiation from an object at increasing temperatures
1698-
hsv red-yellow-green-cyan-blue-pink-magenta, formed by
1699-
changing the hue component in the HSV color space;
1700-
meant to be used in plotting periodic data (that is,
1701-
in which the maximum magnitude and the minimum
1702-
magnitude are equivalent)
1703-
jet blue-cyan-yellow-red, a variant of hsv; based on a
1704-
fluid-jet simulation by NCSA [#]_
1700+
hsv cyclic red-yellow-green-cyan-blue-magenta-red, formed
1701+
by changing the hue component in the HSV color space
1702+
jet a spectral map with dark endpoints, blue-cyan-yellow-red;
1703+
based on a fluid-jet simulation by NCSA [#]_
17051704
pink sequential increasing pastel black-pink-white, meant
17061705
for sepia tone colorization of photographs
1707-
prism repeating red-yellow-green-blue-purple-...-green pattern
1708-
spring shades of magenta-yellow
1709-
summer shades of green-yellow
1710-
winter shades of blue-green
1706+
prism repetitive red-yellow-green-blue-purple-...-green pattern
1707+
(not cyclic at endpoints)
1708+
spring linearly-increasing shades of magenta-yellow
1709+
summer sequential linearly-increasing shades of green-yellow
1710+
winter linearly-increasing shades of blue-green
17111711
spectral black-purple-blue-green-yellow-red-white spectrum
17121712
========= =======================================================
17131713
1714-
The next 7 palettes are from the `Yorick scientific visualisation
1714+
For the above list only, you can also set the colormap using the
1715+
corresponding pylab shortcut interface function, similar to Matlab::
1716+
1717+
imshow(X)
1718+
hot()
1719+
jet()
1720+
1721+
The next set of palettes are from the `Yorick scientific visualisation
17151722
package <http://yorick.sourceforge.net/index.php>`_, an evolution of
17161723
the GIST package, both by David H. Munro:
17171724
@@ -1720,56 +1727,70 @@ def colormaps():
17201727
============ =======================================================
17211728
gist_earth mapmaker's colors from dark blue deep ocean to green
17221729
lowlands to brown highlands to white mountains
1723-
gist_gray (identical to *gray*)
1724-
gist_heat sequential red-orange-yellow-white, to emulate blackbody
1725-
radiation from an iron bar as it grows hotter
1726-
gist_ncar pseudo-spectral colormap from National Center for
1727-
Atmospheric Research [#]_
1728-
gist_rainbow runs through the colors in spectral order at nearly
1729-
constant intensity
1730+
gist_heat sequential increasing black-red-orange-white, to emulate
1731+
blackbody radiation from an iron bar as it grows hotter
1732+
gist_ncar pseudo-spectral black-blue-green-yellow-red-purple-white
1733+
colormap from National Center for Atmospheric
1734+
Research [#]_
1735+
gist_rainbow runs through the colors in spectral order from red to
1736+
violet at full saturation (like *hsv* but not cyclic)
17301737
gist_stern "Stern special" color table from Interactive Data
17311738
Language software
1732-
gist_yarg (identical to *gray_r*)
17331739
============ =======================================================
17341740
1735-
The following 34 colormaps are based on the `ColorBrewer
1741+
The following colormaps are based on the `ColorBrewer
17361742
<http://colorbrewer.org>`_ color specifications and designs developed by
17371743
Cynthia Brewer:
17381744
1739-
Diverging:
1740-
1741-
* BrBG
1742-
* PiYG
1743-
* PRGn
1744-
* PuOr
1745-
* RdBu
1746-
* RdGy
1747-
* RdYlBu
1748-
* RdYlGn
1749-
* Spectral
1750-
1751-
Sequential:
1752-
1753-
* Blues
1754-
* BuGn
1755-
* BuPu
1756-
* GnBu
1757-
* Greens
1758-
* Greys
1759-
* Oranges
1760-
* OrRd
1761-
* PuBu
1762-
* PuBuGn
1763-
* PuRd
1764-
* Purples
1765-
* RdPu
1766-
* Reds
1767-
* YlGn
1768-
* YlGnBu
1769-
* YlOrBr
1770-
* YlOrRd
1771-
1772-
Qualitative:
1745+
ColorBrewer Diverging (luminance is highest at the midpoint, and
1746+
decreases towards differently-colored endpoints):
1747+
1748+
======== ===================================
1749+
Colormap Description
1750+
======== ===================================
1751+
BrBG brown, white, blue-green
1752+
PiYG pink, white, yellow-green
1753+
PRGn purple, white, green
1754+
PuOr orange, white, purple
1755+
RdBu red, white, blue
1756+
RdGy red, white, gray
1757+
RdYlBu red, yellow, blue
1758+
RdYlGn red, yellow, green
1759+
Spectral red, orange, yellow, green, blue
1760+
======== ===================================
1761+
1762+
ColorBrewer Sequential (luminance decreases monotonically):
1763+
1764+
======== ====================================
1765+
Colormap Description
1766+
======== ====================================
1767+
Blues white to dark blue
1768+
BuGn white, light blue, dark green
1769+
BuPu white, light blue, dark purple
1770+
GnBu white, light green, dark blue
1771+
Greens white to dark green
1772+
Greys white to black (not linear)
1773+
Oranges white, orange, dark brown
1774+
OrRd white, orange, dark red
1775+
PuBu white, light purple, dark blue
1776+
PuBuGn white, light purple, dark green
1777+
PuRd white, light purple, dark red
1778+
Purples white to dark purple
1779+
RdPu white, pink, dark purple
1780+
Reds white to dark red
1781+
YlGn light yellow, dark green
1782+
YlGnBu light yellow, light green, dark blue
1783+
YlOrBr light yellow, orange, dark brown
1784+
YlOrRd light yellow, orange, dark red
1785+
======== ====================================
1786+
1787+
ColorBrewer Qualitative:
1788+
1789+
(For plotting nominal data, :class:`ListedColormap` should be used,
1790+
not :class:`LinearSegmentedColormap`. Different sets of colors are
1791+
recommended for different numbers of categories. These continuous
1792+
versions of the qualitative schemes may be removed or converted in the
1793+
future.)
17731794
17741795
* Accent
17751796
* Dark2
@@ -1787,7 +1808,6 @@ def colormaps():
17871808
========= =======================================================
17881809
afmhot sequential black-orange-yellow-white blackbody
17891810
spectrum, commonly used in atomic force microscopy
1790-
binary (identical to *gray_r*)
17911811
brg blue-red-green
17921812
bwr diverging blue-white-red
17931813
coolwarm diverging blue-gray-red, meant to avoid issues with 3D
@@ -1810,20 +1830,34 @@ def colormaps():
18101830
gnuplot2 sequential color printable as gray
18111831
(black-blue-violet-yellow-white)
18121832
ocean green-blue-white
1813-
rainbow purple-blue-green-yellow-orange-red
1833+
rainbow spectral purple-blue-green-yellow-orange-red colormap
1834+
with diverging luminance
18141835
seismic diverging blue-white-red
18151836
terrain mapmaker's colors, blue-green-yellow-brown-white,
18161837
originally from IGOR Pro
18171838
========= =======================================================
18181839
1840+
The following colormaps are redundant and may be removed in future
1841+
versions. It's recommended to use *gray* or *gray_r* instead, which
1842+
produce identical output:
1843+
1844+
========= =======================================================
1845+
Colormap Description
1846+
========= =======================================================
1847+
gist_gray identical to *gray*
1848+
gist_yarg identical to *gray_r*
1849+
binary identical to *gray_r*
1850+
========= =======================================================
1851+
18191852
.. rubric:: Footnotes
18201853
18211854
.. [#] Rainbow colormaps, ``jet`` in particular, are considered a poor
18221855
choice for scientific visualization by many researchers: `Rainbow Color
18231856
Map (Still) Considered Harmful
18241857
<http://www.jwave.vt.edu/%7Erkriz/Projects/create_color_table/color_07.pdf>`_
18251858
1826-
.. [#] Resembles "BkBlAqGrYeOrReViWh200" from `Color Table Gallery
1859+
.. [#] Resembles "BkBlAqGrYeOrReViWh200" from NCAR Command
1860+
Language. See `Color Table Gallery
18271861
<http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml>`_
18281862
18291863
.. [#] See `Diverging Color Maps for Scientific Visualization

0 commit comments

Comments
 (0)