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

Skip to content

Commit 73fb325

Browse files
committed
update colormaps docstring with more maps, their origins and purposes as best I can tell
1 parent fbbf5bb commit 73fb325

File tree

1 file changed

+153
-19
lines changed

1 file changed

+153
-19
lines changed

lib/matplotlib/pyplot.py

Lines changed: 153 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,37 +1645,171 @@ def colors():
16451645

16461646
def colormaps():
16471647
"""
1648-
matplotlib provides the following colormaps.
1649-
1650-
* autumn
1651-
* bone
1652-
* cool
1653-
* copper
1654-
* flag
1655-
* gray
1656-
* hot
1657-
* hsv
1658-
* jet
1659-
* pink
1660-
* prism
1661-
* spring
1662-
* summer
1663-
* winter
1664-
* spectral
1648+
matplotlib provides a number of colormaps, a complete list of which can be found in `cm._cmapnames`.
16651649
16661650
You can set the colormap for an image, pcolor, scatter, etc,
1667-
either as a keyword argument::
1651+
using a keyword argument::
16681652
16691653
imshow(X, cmap=cm.hot)
16701654
1671-
or post-hoc using the corresponding pylab interface function::
1655+
Additionally, for the "base" colormaps below, you can set the colormap post-hoc using the corresponding pylab interface function::
16721656
16731657
imshow(X)
16741658
hot()
16751659
jet()
16761660
16771661
In interactive mode, this will update the colormap allowing you to
16781662
see which one works best for your data.
1663+
1664+
All colormaps can be reversed by appending ``_r``: For instance,
1665+
``gray_r`` is the reverse of ``gray``.
1666+
1667+
There are 3 common color schemes used in visualization:
1668+
1669+
1. Sequential schemes, for unipolar data that progresses from low to high
1670+
2. Diverging schemes, for bipolar data that emphasizes positive or negative deviations from a central value
1671+
3. Qualitative schemes, which don't have a relationship to magnitude
1672+
1673+
The base colormaps are:
1674+
1675+
========= =======================================================
1676+
Colormap Description
1677+
========= =======================================================
1678+
autumn sequential increasing shades of red-orange-yellow
1679+
bone sequential black-white color map with a tinge of blue,
1680+
to emulate X-ray film
1681+
cool sequential decreasing shades of cyan-magenta
1682+
copper sequential increasing shades of black-copper
1683+
flag repeating red-white-blue-black pattern
1684+
gray simple sequential linearly-increasing black-to-white
1685+
grayscale
1686+
hot sequential black-red-yellow-white, to emulate blackbody
1687+
radiation from an object at increasing temperatures
1688+
hsv red-yellow-green-cyan-blue-pink-magenta, formed by
1689+
changing the hue component in the HSV color space;
1690+
meant to be used in plotting periodic data (that is,
1691+
in which the maximum magnitude and the minimum
1692+
magnitude are equivalent)
1693+
jet blue-cyan-yellow-red, a variant of hsv; based on a
1694+
fluid-jet simulation by NCSA [#]_
1695+
pink sequential increasing pastel black-pink-white, meant
1696+
for sepia tone colorization of photographs
1697+
prism repeating red-yellow-green-blue-purple-...-green pattern
1698+
spring shades of magenta-yellow
1699+
summer shades of green-yellow
1700+
winter shades of blue-green
1701+
spectral black-purple-blue-green-yellow-red-white spectrum
1702+
========= =======================================================
1703+
1704+
The next 7 palettes are from the `Yorick scientific visualisation
1705+
package <http://yorick.sourceforge.net/index.php>`_, an evolution of the GIST package, both by David H. Munro:
1706+
1707+
============ =======================================================
1708+
Colormap Description
1709+
============ =======================================================
1710+
gist_earth mapmaker's colors from dark blue deep ocean to green
1711+
lowlands to brown highlands to white mountains
1712+
gist_gray (identical to *gray*)
1713+
gist_heat sequential red-orange-yellow-white, to emulate blackbody
1714+
radiation from an iron bar as it grows hotter
1715+
gist_ncar pseudo-spectral colormap from National Center for Atmospheric Research [#]_
1716+
gist_rainbow runs through the colors in spectral order at nearly constant intensity
1717+
gist_stern "Stern special" color table from Interactive Data Language software
1718+
gist_yarg (identical to *gray_r*)
1719+
============ =======================================================
1720+
1721+
The following 34 colormaps are based on the `ColorBrewer <http://colorbrewer.org>`_ color specifications and designs developed by Cynthia Brewer:
1722+
1723+
Diverging:
1724+
1725+
* BrBG
1726+
* PiYG
1727+
* PRGn
1728+
* PuOr
1729+
* RdBu
1730+
* RdGy
1731+
* RdYlBu
1732+
* RdYlGn
1733+
* Spectral
1734+
1735+
Sequential:
1736+
1737+
* Blues
1738+
* BuGn
1739+
* BuPu
1740+
* GnBu
1741+
* Greens
1742+
* Greys
1743+
* Oranges
1744+
* OrRd
1745+
* PuBu
1746+
* PuBuGn
1747+
* PuRd
1748+
* Purples
1749+
* RdPu
1750+
* Reds
1751+
* YlGn
1752+
* YlGnBu
1753+
* YlOrBr
1754+
* YlOrRd
1755+
1756+
Qualitative:
1757+
1758+
* Accent
1759+
* Dark2
1760+
* Paired
1761+
* Pastel1
1762+
* Pastel2
1763+
* Set1
1764+
* Set2
1765+
* Set3
1766+
1767+
Other miscellaneous schemes:
1768+
1769+
========= =======================================================
1770+
Colormap Description
1771+
========= =======================================================
1772+
afmhot sequential black-orange-yellow-white blackbody
1773+
spectrum, commonly used in atomic force microscopy
1774+
binary (identical to *gray_r*)
1775+
brg blue-red-green
1776+
bwr diverging blue-white-red
1777+
coolwarm diverging blue-gray-red, meant to avoid issues with 3D
1778+
shading, color blindness, and ordering of colors [#]_
1779+
CMRmap "Default colormaps on color images often reproduce to
1780+
confusing grayscale images. The proposed colormap
1781+
maintains an aesthetically pleasing color image that
1782+
automatically reproduces to a monotonic grayscale with
1783+
discrete, quantifiable saturation levels." [#]_
1784+
cubehelix Unlike most other color schemes cubehelix was designed
1785+
by D.A. Green to be monotonically increasing in terms
1786+
of perceived brightness. Also, when printed on a black
1787+
and white postscript printer, the scheme results in a
1788+
greyscale with monotonically increasing brightness.
1789+
This color scheme is named cubehelix because the r,g,b
1790+
values produced can be visualised as a squashed helix
1791+
around the diagonal in the r,g,b color cube.
1792+
gnuplot gnuplot's traditional pm3d scheme
1793+
(black-blue-red-yellow)
1794+
gnuplot2 sequential color printable as gray
1795+
(black-blue-violet-yellow-white)
1796+
ocean green-blue-white
1797+
rainbow purple-blue-green-yellow-orange-red
1798+
seismic diverging blue-white-red
1799+
terrain mapmaker's colors, blue-green-yellow-brown-white,
1800+
originally from IGOR Pro
1801+
========= =======================================================
1802+
1803+
.. rubric:: Footnotes
1804+
1805+
.. [#] Rainbow colormaps, `jet` in particular, are considered a poor choice for scientific visualization by many researchers: `Rainbow Color Map (Still) Considered Harmful <http://www.jwave.vt.edu/%7Erkriz/Projects/create_color_table/color_07.pdf>`_
1806+
1807+
.. [#] Resembles "BkBlAqGrYeOrReViWh200" from `Color Table Gallery <http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml>`_
1808+
1809+
.. [#] See `Diverging Color Maps for Scientific Visualization <http://www.cs.unm.edu/~kmorel/documents/ColorMaps/>`_ by Kenneth Moreland.
1810+
1811+
.. [#] See `A Color Map for Effective Black-and-White Rendering of Color-Scale Images <http://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m>`_ by Carey Rappaport
1812+
16791813
"""
16801814
pass
16811815

0 commit comments

Comments
 (0)