Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b79b55d

Browse filesBrowse files
committed
Merge pull request #1127 from endolith/patch-9
Change spectral to nipy_spectral, update docs, leave aliases
2 parents 71af83c + 5fca395 commit b79b55d
Copy full SHA for b79b55d

File tree

Expand file treeCollapse file tree

2 files changed

+83
-72
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+83
-72
lines changed

‎lib/matplotlib/_cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_cm.py
+38-34Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Nothing here but dictionaries for generating LinearSegmentedColormaps,
33
and a dictionary of these dictionaries.
44
5+
Documentation for each is in pyplot.colormaps()
56
"""
67

78
from __future__ import print_function, division
@@ -462,39 +463,41 @@ def gfunc32(x):
462463
'green': ((0., 0., 0.), (1.0, 1.0, 1.0)),
463464
'blue': ((0., 1., 1.), (1.0, 0.5, 0.5))}
464465

465-
_spectral_data = {'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667),
466-
(0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0),
467-
(0.20, 0.0, 0.0), (0.25, 0.0, 0.0),
468-
(0.30, 0.0, 0.0), (0.35, 0.0, 0.0),
469-
(0.40, 0.0, 0.0), (0.45, 0.0, 0.0),
470-
(0.50, 0.0, 0.0), (0.55, 0.0, 0.0),
471-
(0.60, 0.0, 0.0), (0.65, 0.7333, 0.7333),
472-
(0.70, 0.9333, 0.9333), (0.75, 1.0, 1.0),
473-
(0.80, 1.0, 1.0), (0.85, 1.0, 1.0),
474-
(0.90, 0.8667, 0.8667), (0.95, 0.80, 0.80),
475-
(1.0, 0.80, 0.80)],
476-
'green': [(0.0, 0.0, 0.0), (0.05, 0.0, 0.0),
477-
(0.10, 0.0, 0.0), (0.15, 0.0, 0.0),
478-
(0.20, 0.0, 0.0), (0.25, 0.4667, 0.4667),
479-
(0.30, 0.6000, 0.6000), (0.35, 0.6667, 0.6667),
480-
(0.40, 0.6667, 0.6667), (0.45, 0.6000, 0.6000),
481-
(0.50, 0.7333, 0.7333), (0.55, 0.8667, 0.8667),
482-
(0.60, 1.0, 1.0), (0.65, 1.0, 1.0),
483-
(0.70, 0.9333, 0.9333), (0.75, 0.8000, 0.8000),
484-
(0.80, 0.6000, 0.6000), (0.85, 0.0, 0.0),
485-
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
486-
(1.0, 0.80, 0.80)],
487-
'blue': [(0.0, 0.0, 0.0), (0.05, 0.5333, 0.5333),
488-
(0.10, 0.6000, 0.6000), (0.15, 0.6667, 0.6667),
489-
(0.20, 0.8667, 0.8667), (0.25, 0.8667, 0.8667),
490-
(0.30, 0.8667, 0.8667), (0.35, 0.6667, 0.6667),
491-
(0.40, 0.5333, 0.5333), (0.45, 0.0, 0.0),
492-
(0.5, 0.0, 0.0), (0.55, 0.0, 0.0),
493-
(0.60, 0.0, 0.0), (0.65, 0.0, 0.0),
494-
(0.70, 0.0, 0.0), (0.75, 0.0, 0.0),
495-
(0.80, 0.0, 0.0), (0.85, 0.0, 0.0),
496-
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
497-
(1.0, 0.80, 0.80)]}
466+
_nipy_spectral_data = {
467+
'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667),
468+
(0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0),
469+
(0.20, 0.0, 0.0), (0.25, 0.0, 0.0),
470+
(0.30, 0.0, 0.0), (0.35, 0.0, 0.0),
471+
(0.40, 0.0, 0.0), (0.45, 0.0, 0.0),
472+
(0.50, 0.0, 0.0), (0.55, 0.0, 0.0),
473+
(0.60, 0.0, 0.0), (0.65, 0.7333, 0.7333),
474+
(0.70, 0.9333, 0.9333), (0.75, 1.0, 1.0),
475+
(0.80, 1.0, 1.0), (0.85, 1.0, 1.0),
476+
(0.90, 0.8667, 0.8667), (0.95, 0.80, 0.80),
477+
(1.0, 0.80, 0.80)],
478+
'green': [(0.0, 0.0, 0.0), (0.05, 0.0, 0.0),
479+
(0.10, 0.0, 0.0), (0.15, 0.0, 0.0),
480+
(0.20, 0.0, 0.0), (0.25, 0.4667, 0.4667),
481+
(0.30, 0.6000, 0.6000), (0.35, 0.6667, 0.6667),
482+
(0.40, 0.6667, 0.6667), (0.45, 0.6000, 0.6000),
483+
(0.50, 0.7333, 0.7333), (0.55, 0.8667, 0.8667),
484+
(0.60, 1.0, 1.0), (0.65, 1.0, 1.0),
485+
(0.70, 0.9333, 0.9333), (0.75, 0.8000, 0.8000),
486+
(0.80, 0.6000, 0.6000), (0.85, 0.0, 0.0),
487+
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
488+
(1.0, 0.80, 0.80)],
489+
'blue': [(0.0, 0.0, 0.0), (0.05, 0.5333, 0.5333),
490+
(0.10, 0.6000, 0.6000), (0.15, 0.6667, 0.6667),
491+
(0.20, 0.8667, 0.8667), (0.25, 0.8667, 0.8667),
492+
(0.30, 0.8667, 0.8667), (0.35, 0.6667, 0.6667),
493+
(0.40, 0.5333, 0.5333), (0.45, 0.0, 0.0),
494+
(0.5, 0.0, 0.0), (0.55, 0.0, 0.0),
495+
(0.60, 0.0, 0.0), (0.65, 0.0, 0.0),
496+
(0.70, 0.0, 0.0), (0.75, 0.0, 0.0),
497+
(0.80, 0.0, 0.0), (0.85, 0.0, 0.0),
498+
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
499+
(1.0, 0.80, 0.80)],
500+
}
498501

499502

500503
# 34 colormaps based on color specifications and designs
@@ -1911,7 +1914,8 @@ def gfunc32(x):
19111914
'summer': _summer_data,
19121915
'terrain': _terrain_data,
19131916
'winter': _winter_data,
1914-
'spectral': _spectral_data
1917+
'nipy_spectral': _nipy_spectral_data,
1918+
'spectral': _nipy_spectral_data, # alias for backward compatibility
19151919
}
19161920

19171921

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+45-38Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,8 +1762,8 @@ def colormaps():
17621762
for nominal data that has no inherent ordering, where color is used
17631763
only to distinguish categories
17641764
1765-
The base colormaps are (with the exception of `spectral`) derived from
1766-
those of the same name provided with Matlab:
1765+
The base colormaps are derived from those of the same name provided
1766+
with Matlab:
17671767
17681768
========= =======================================================
17691769
Colormap Description
@@ -1790,7 +1790,6 @@ def colormaps():
17901790
spring linearly-increasing shades of magenta-yellow
17911791
summer sequential linearly-increasing shades of green-yellow
17921792
winter linearly-increasing shades of blue-green
1793-
spectral black-purple-blue-green-yellow-red-white spectrum
17941793
========= =======================================================
17951794
17961795
For the above list only, you can also set the colormap using the
@@ -1885,50 +1884,53 @@ def colormaps():
18851884
18861885
Other miscellaneous schemes:
18871886
1888-
========= =======================================================
1889-
Colormap Description
1890-
========= =======================================================
1891-
afmhot sequential black-orange-yellow-white blackbody
1892-
spectrum, commonly used in atomic force microscopy
1893-
brg blue-red-green
1894-
bwr diverging blue-white-red
1895-
coolwarm diverging blue-gray-red, meant to avoid issues with 3D
1896-
shading, color blindness, and ordering of colors [#]_
1897-
CMRmap "Default colormaps on color images often reproduce to
1898-
confusing grayscale images. The proposed colormap
1899-
maintains an aesthetically pleasing color image that
1900-
automatically reproduces to a monotonic grayscale with
1901-
discrete, quantifiable saturation levels." [#]_
1902-
cubehelix Unlike most other color schemes cubehelix was designed
1903-
by D.A. Green to be monotonically increasing in terms
1904-
of perceived brightness. Also, when printed on a black
1905-
and white postscript printer, the scheme results in a
1906-
greyscale with monotonically increasing brightness.
1907-
This color scheme is named cubehelix because the r,g,b
1908-
values produced can be visualised as a squashed helix
1909-
around the diagonal in the r,g,b color cube.
1910-
gnuplot gnuplot's traditional pm3d scheme
1911-
(black-blue-red-yellow)
1912-
gnuplot2 sequential color printable as gray
1913-
(black-blue-violet-yellow-white)
1914-
ocean green-blue-white
1915-
rainbow spectral purple-blue-green-yellow-orange-red colormap
1916-
with diverging luminance
1917-
seismic diverging blue-white-red
1918-
terrain mapmaker's colors, blue-green-yellow-brown-white,
1919-
originally from IGOR Pro
1920-
========= =======================================================
1887+
============= =======================================================
1888+
Colormap Description
1889+
============= =======================================================
1890+
afmhot sequential black-orange-yellow-white blackbody
1891+
spectrum, commonly used in atomic force microscopy
1892+
brg blue-red-green
1893+
bwr diverging blue-white-red
1894+
coolwarm diverging blue-gray-red, meant to avoid issues with 3D
1895+
shading, color blindness, and ordering of colors [#]_
1896+
CMRmap "Default colormaps on color images often reproduce to
1897+
confusing grayscale images. The proposed colormap
1898+
maintains an aesthetically pleasing color image that
1899+
automatically reproduces to a monotonic grayscale with
1900+
discrete, quantifiable saturation levels." [#]_
1901+
cubehelix Unlike most other color schemes cubehelix was designed
1902+
by D.A. Green to be monotonically increasing in terms
1903+
of perceived brightness. Also, when printed on a black
1904+
and white postscript printer, the scheme results in a
1905+
greyscale with monotonically increasing brightness.
1906+
This color scheme is named cubehelix because the r,g,b
1907+
values produced can be visualised as a squashed helix
1908+
around the diagonal in the r,g,b color cube.
1909+
gnuplot gnuplot's traditional pm3d scheme
1910+
(black-blue-red-yellow)
1911+
gnuplot2 sequential color printable as gray
1912+
(black-blue-violet-yellow-white)
1913+
ocean green-blue-white
1914+
rainbow spectral purple-blue-green-yellow-orange-red colormap
1915+
with diverging luminance
1916+
seismic diverging blue-white-red
1917+
nipy_spectral black-purple-blue-green-yellow-red-white spectrum,
1918+
originally from the Neuroimaging in Python project
1919+
terrain mapmaker's colors, blue-green-yellow-brown-white,
1920+
originally from IGOR Pro
1921+
============= =======================================================
19211922
19221923
The following colormaps are redundant and may be removed in future
1923-
versions. It's recommended to use *gray* or *gray_r* instead, which
1924-
produce identical output:
1924+
versions. It's recommended to use the names in the descriptions
1925+
instead, which produce identical output:
19251926
19261927
========= =======================================================
19271928
Colormap Description
19281929
========= =======================================================
19291930
gist_gray identical to *gray*
19301931
gist_yarg identical to *gray_r*
19311932
binary identical to *gray_r*
1933+
spectral identical to *nipy_spectral* [#]_
19321934
========= =======================================================
19331935
19341936
.. rubric:: Footnotes
@@ -1950,6 +1952,11 @@ def colormaps():
19501952
Color-Scale Images
19511953
<http://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m>`_
19521954
by Carey Rappaport
1955+
1956+
.. [#] Changed to distinguish from ColorBrewer's *Spectral* map.
1957+
:func:`spectral` still works, but
1958+
``set_cmap('nipy_spectral')`` is recommended for clarity.
1959+
19531960
19541961
"""
19551962
return sorted(cm.cmap_d.keys())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.