From 2b5521ddcc1b348c77221de212dbcdf6d4d2a92b Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 20 Aug 2012 13:41:08 -0300 Subject: [PATCH 1/3] Start to update docs for spectral/Spectral change --- lib/matplotlib/pyplot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index ce4c53fcb6c8..1b635cec5e6f 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1744,7 +1744,6 @@ def colormaps(): spring linearly-increasing shades of magenta-yellow summer sequential linearly-increasing shades of green-yellow winter linearly-increasing shades of blue-green - spectral black-purple-blue-green-yellow-red-white spectrum ========= ======================================================= For the above list only, you can also set the colormap using the @@ -1869,6 +1868,7 @@ def colormaps(): rainbow spectral purple-blue-green-yellow-orange-red colormap with diverging luminance seismic diverging blue-white-red + nipy_spectral black-purple-blue-green-yellow-red-white spectrum, originally from the Neuroimaging in Python project terrain mapmaker's colors, blue-green-yellow-brown-white, originally from IGOR Pro ========= ======================================================= @@ -1883,6 +1883,7 @@ def colormaps(): gist_gray identical to *gray* gist_yarg identical to *gray_r* binary identical to *gray_r* + spectral identical to *nipy_spectral*, which was changed to differentiate from ColorBrewer's Spectral map ========= ======================================================= .. rubric:: Footnotes From 6e3a6aefe1f2dc2bec7430753e0ff3352f2d640d Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 21 Aug 2012 12:44:43 -0400 Subject: [PATCH 2/3] change spectral to nipy_spectral, leave spectral as alias, update docs --- lib/matplotlib/_cm.py | 6 ++- lib/matplotlib/pyplot.py | 84 +++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index cd3bedf04eae..d350c6f425c6 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -2,6 +2,7 @@ Nothing here but dictionaries for generating LinearSegmentedColormaps, and a dictionary of these dictionaries. +Documentation for each is in pyplot.colormaps() """ from __future__ import print_function @@ -342,7 +343,7 @@ def gfunc32(x): 'green': ((0., 0., 0.),(1.0, 1.0, 1.0)), 'blue': ((0., 1., 1.),(1.0, 0.5, 0.5))} -_spectral_data = {'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667), +_nipy_spectral_data = {'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667), (0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0), (0.20, 0.0, 0.0), (0.25, 0.0, 0.0), (0.30, 0.0, 0.0), (0.35, 0.0, 0.0), @@ -1790,7 +1791,8 @@ def gfunc32(x): 'summer': _summer_data, 'terrain': _terrain_data, 'winter': _winter_data, - 'spectral': _spectral_data + 'nipy_spectral': _nipy_spectral_data, + 'spectral': _nipy_spectral_data, # alias for backward compatibility } diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 1b635cec5e6f..46fdec94ba49 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1716,8 +1716,8 @@ def colormaps(): for nominal data that has no inherent ordering, where color is used only to distinguish categories - The base colormaps are (with the exception of `spectral`) derived from - those of the same name provided with Matlab: + The base colormaps are derived from those of the same name provided + with Matlab: ========= ======================================================= Colormap Description @@ -1838,44 +1838,45 @@ def colormaps(): Other miscellaneous schemes: - ========= ======================================================= - Colormap Description - ========= ======================================================= - afmhot sequential black-orange-yellow-white blackbody - spectrum, commonly used in atomic force microscopy - brg blue-red-green - bwr diverging blue-white-red - coolwarm diverging blue-gray-red, meant to avoid issues with 3D - shading, color blindness, and ordering of colors [#]_ - CMRmap "Default colormaps on color images often reproduce to - confusing grayscale images. The proposed colormap - maintains an aesthetically pleasing color image that - automatically reproduces to a monotonic grayscale with - discrete, quantifiable saturation levels." [#]_ - cubehelix Unlike most other color schemes cubehelix was designed - by D.A. Green to be monotonically increasing in terms - of perceived brightness. Also, when printed on a black - and white postscript printer, the scheme results in a - greyscale with monotonically increasing brightness. - This color scheme is named cubehelix because the r,g,b - values produced can be visualised as a squashed helix - around the diagonal in the r,g,b color cube. - gnuplot gnuplot's traditional pm3d scheme - (black-blue-red-yellow) - gnuplot2 sequential color printable as gray - (black-blue-violet-yellow-white) - ocean green-blue-white - rainbow spectral purple-blue-green-yellow-orange-red colormap - with diverging luminance - seismic diverging blue-white-red - nipy_spectral black-purple-blue-green-yellow-red-white spectrum, originally from the Neuroimaging in Python project - terrain mapmaker's colors, blue-green-yellow-brown-white, - originally from IGOR Pro - ========= ======================================================= + ============= ======================================================= + Colormap Description + ============= ======================================================= + afmhot sequential black-orange-yellow-white blackbody + spectrum, commonly used in atomic force microscopy + brg blue-red-green + bwr diverging blue-white-red + coolwarm diverging blue-gray-red, meant to avoid issues with 3D + shading, color blindness, and ordering of colors [#]_ + CMRmap "Default colormaps on color images often reproduce to + confusing grayscale images. The proposed colormap + maintains an aesthetically pleasing color image that + automatically reproduces to a monotonic grayscale with + discrete, quantifiable saturation levels." [#]_ + cubehelix Unlike most other color schemes cubehelix was designed + by D.A. Green to be monotonically increasing in terms + of perceived brightness. Also, when printed on a black + and white postscript printer, the scheme results in a + greyscale with monotonically increasing brightness. + This color scheme is named cubehelix because the r,g,b + values produced can be visualised as a squashed helix + around the diagonal in the r,g,b color cube. + gnuplot gnuplot's traditional pm3d scheme + (black-blue-red-yellow) + gnuplot2 sequential color printable as gray + (black-blue-violet-yellow-white) + ocean green-blue-white + rainbow spectral purple-blue-green-yellow-orange-red colormap + with diverging luminance + seismic diverging blue-white-red + nipy_spectral black-purple-blue-green-yellow-red-white spectrum, + originally from the Neuroimaging in Python project + terrain mapmaker's colors, blue-green-yellow-brown-white, + originally from IGOR Pro + ============= ======================================================= The following colormaps are redundant and may be removed in future - versions. It's recommended to use *gray* or *gray_r* instead, which - produce identical output: + versions. It's recommended to use the names in the descriptions + instead, which produce identical output: ========= ======================================================= Colormap Description @@ -1883,7 +1884,7 @@ def colormaps(): gist_gray identical to *gray* gist_yarg identical to *gray_r* binary identical to *gray_r* - spectral identical to *nipy_spectral*, which was changed to differentiate from ColorBrewer's Spectral map + spectral identical to *nipy_spectral* [#]_ ========= ======================================================= .. rubric:: Footnotes @@ -1905,6 +1906,11 @@ def colormaps(): Color-Scale Images `_ by Carey Rappaport + + .. [#] Changed to distinguish from ColorBrewer's *Spectral* map. + :func:`spectral` still works, but + `set_cmap('nipy_spectral')` is recommended for clarity. + """ return sorted(cm.cmap_d.keys()) From 5fca3951f172ac8d89584957a02c306d7d6574e9 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 21 Aug 2012 16:06:32 -0400 Subject: [PATCH 3/3] align nipy_spectral_data, double backquotes --- lib/matplotlib/_cm.py | 68 +++++++++++++++++++++------------------- lib/matplotlib/pyplot.py | 2 +- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index d350c6f425c6..c42777cbf9fe 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -343,39 +343,41 @@ def gfunc32(x): 'green': ((0., 0., 0.),(1.0, 1.0, 1.0)), 'blue': ((0., 1., 1.),(1.0, 0.5, 0.5))} -_nipy_spectral_data = {'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667), - (0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0), - (0.20, 0.0, 0.0), (0.25, 0.0, 0.0), - (0.30, 0.0, 0.0), (0.35, 0.0, 0.0), - (0.40, 0.0, 0.0), (0.45, 0.0, 0.0), - (0.50, 0.0, 0.0), (0.55, 0.0, 0.0), - (0.60, 0.0, 0.0), (0.65, 0.7333, 0.7333), - (0.70, 0.9333, 0.9333), (0.75, 1.0, 1.0), - (0.80, 1.0, 1.0), (0.85, 1.0, 1.0), - (0.90, 0.8667, 0.8667), (0.95, 0.80, 0.80), - (1.0, 0.80, 0.80)], - 'green': [(0.0, 0.0, 0.0), (0.05, 0.0, 0.0), - (0.10, 0.0, 0.0), (0.15, 0.0, 0.0), - (0.20, 0.0, 0.0), (0.25, 0.4667, 0.4667), - (0.30, 0.6000, 0.6000), (0.35, 0.6667, 0.6667), - (0.40, 0.6667, 0.6667), (0.45, 0.6000, 0.6000), - (0.50, 0.7333, 0.7333), (0.55, 0.8667, 0.8667), - (0.60, 1.0, 1.0), (0.65, 1.0, 1.0), - (0.70, 0.9333, 0.9333), (0.75, 0.8000, 0.8000), - (0.80, 0.6000, 0.6000), (0.85, 0.0, 0.0), - (0.90, 0.0, 0.0), (0.95, 0.0, 0.0), - (1.0, 0.80, 0.80)], - 'blue': [(0.0, 0.0, 0.0), (0.05, 0.5333, 0.5333), - (0.10, 0.6000, 0.6000), (0.15, 0.6667, 0.6667), - (0.20, 0.8667, 0.8667), (0.25, 0.8667, 0.8667), - (0.30, 0.8667, 0.8667), (0.35, 0.6667, 0.6667), - (0.40, 0.5333, 0.5333), (0.45, 0.0, 0.0), - (0.5, 0.0, 0.0), (0.55, 0.0, 0.0), - (0.60, 0.0, 0.0), (0.65, 0.0, 0.0), - (0.70, 0.0, 0.0), (0.75, 0.0, 0.0), - (0.80, 0.0, 0.0), (0.85, 0.0, 0.0), - (0.90, 0.0, 0.0), (0.95, 0.0, 0.0), - (1.0, 0.80, 0.80)]} +_nipy_spectral_data = { + 'red': [(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667), + (0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0), + (0.20, 0.0, 0.0), (0.25, 0.0, 0.0), + (0.30, 0.0, 0.0), (0.35, 0.0, 0.0), + (0.40, 0.0, 0.0), (0.45, 0.0, 0.0), + (0.50, 0.0, 0.0), (0.55, 0.0, 0.0), + (0.60, 0.0, 0.0), (0.65, 0.7333, 0.7333), + (0.70, 0.9333, 0.9333), (0.75, 1.0, 1.0), + (0.80, 1.0, 1.0), (0.85, 1.0, 1.0), + (0.90, 0.8667, 0.8667), (0.95, 0.80, 0.80), + (1.0, 0.80, 0.80)], + 'green': [(0.0, 0.0, 0.0), (0.05, 0.0, 0.0), + (0.10, 0.0, 0.0), (0.15, 0.0, 0.0), + (0.20, 0.0, 0.0), (0.25, 0.4667, 0.4667), + (0.30, 0.6000, 0.6000), (0.35, 0.6667, 0.6667), + (0.40, 0.6667, 0.6667), (0.45, 0.6000, 0.6000), + (0.50, 0.7333, 0.7333), (0.55, 0.8667, 0.8667), + (0.60, 1.0, 1.0), (0.65, 1.0, 1.0), + (0.70, 0.9333, 0.9333), (0.75, 0.8000, 0.8000), + (0.80, 0.6000, 0.6000), (0.85, 0.0, 0.0), + (0.90, 0.0, 0.0), (0.95, 0.0, 0.0), + (1.0, 0.80, 0.80)], + 'blue': [(0.0, 0.0, 0.0), (0.05, 0.5333, 0.5333), + (0.10, 0.6000, 0.6000), (0.15, 0.6667, 0.6667), + (0.20, 0.8667, 0.8667), (0.25, 0.8667, 0.8667), + (0.30, 0.8667, 0.8667), (0.35, 0.6667, 0.6667), + (0.40, 0.5333, 0.5333), (0.45, 0.0, 0.0), + (0.5, 0.0, 0.0), (0.55, 0.0, 0.0), + (0.60, 0.0, 0.0), (0.65, 0.0, 0.0), + (0.70, 0.0, 0.0), (0.75, 0.0, 0.0), + (0.80, 0.0, 0.0), (0.85, 0.0, 0.0), + (0.90, 0.0, 0.0), (0.95, 0.0, 0.0), + (1.0, 0.80, 0.80)], +} # 34 colormaps based on color specifications and designs diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 46fdec94ba49..a26db669b951 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1909,7 +1909,7 @@ def colormaps(): .. [#] Changed to distinguish from ColorBrewer's *Spectral* map. :func:`spectral` still works, but - `set_cmap('nipy_spectral')` is recommended for clarity. + ``set_cmap('nipy_spectral')`` is recommended for clarity. """