Skip to content

Commit 4f42c68

Browse files
authored
Merge pull request #15275 from mikhailov-work/master
adds turbo colormap
2 parents 0e900cf + f6ca3af commit 4f42c68

File tree

4 files changed

+271
-6
lines changed

4 files changed

+271
-6
lines changed

examples/color/colormap_reference.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
('Miscellaneous', [
3838
'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
3939
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',
40-
'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])]
40+
'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',
41+
'gist_ncar'])]
4142

4243

4344
gradient = np.linspace(0, 1, 256)

lib/matplotlib/_cm_listed.py

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,263 @@
18001800
_twilight_shifted_data = (_twilight_data[len(_twilight_data)//2:] +
18011801
_twilight_data[:len(_twilight_data)//2])
18021802
_twilight_shifted_data.reverse()
1803+
_turbo_data = [[0.18995, 0.07176, 0.23217],
1804+
[0.19483, 0.08339, 0.26149],
1805+
[0.19956, 0.09498, 0.29024],
1806+
[0.20415, 0.10652, 0.31844],
1807+
[0.20860, 0.11802, 0.34607],
1808+
[0.21291, 0.12947, 0.37314],
1809+
[0.21708, 0.14087, 0.39964],
1810+
[0.22111, 0.15223, 0.42558],
1811+
[0.22500, 0.16354, 0.45096],
1812+
[0.22875, 0.17481, 0.47578],
1813+
[0.23236, 0.18603, 0.50004],
1814+
[0.23582, 0.19720, 0.52373],
1815+
[0.23915, 0.20833, 0.54686],
1816+
[0.24234, 0.21941, 0.56942],
1817+
[0.24539, 0.23044, 0.59142],
1818+
[0.24830, 0.24143, 0.61286],
1819+
[0.25107, 0.25237, 0.63374],
1820+
[0.25369, 0.26327, 0.65406],
1821+
[0.25618, 0.27412, 0.67381],
1822+
[0.25853, 0.28492, 0.69300],
1823+
[0.26074, 0.29568, 0.71162],
1824+
[0.26280, 0.30639, 0.72968],
1825+
[0.26473, 0.31706, 0.74718],
1826+
[0.26652, 0.32768, 0.76412],
1827+
[0.26816, 0.33825, 0.78050],
1828+
[0.26967, 0.34878, 0.79631],
1829+
[0.27103, 0.35926, 0.81156],
1830+
[0.27226, 0.36970, 0.82624],
1831+
[0.27334, 0.38008, 0.84037],
1832+
[0.27429, 0.39043, 0.85393],
1833+
[0.27509, 0.40072, 0.86692],
1834+
[0.27576, 0.41097, 0.87936],
1835+
[0.27628, 0.42118, 0.89123],
1836+
[0.27667, 0.43134, 0.90254],
1837+
[0.27691, 0.44145, 0.91328],
1838+
[0.27701, 0.45152, 0.92347],
1839+
[0.27698, 0.46153, 0.93309],
1840+
[0.27680, 0.47151, 0.94214],
1841+
[0.27648, 0.48144, 0.95064],
1842+
[0.27603, 0.49132, 0.95857],
1843+
[0.27543, 0.50115, 0.96594],
1844+
[0.27469, 0.51094, 0.97275],
1845+
[0.27381, 0.52069, 0.97899],
1846+
[0.27273, 0.53040, 0.98461],
1847+
[0.27106, 0.54015, 0.98930],
1848+
[0.26878, 0.54995, 0.99303],
1849+
[0.26592, 0.55979, 0.99583],
1850+
[0.26252, 0.56967, 0.99773],
1851+
[0.25862, 0.57958, 0.99876],
1852+
[0.25425, 0.58950, 0.99896],
1853+
[0.24946, 0.59943, 0.99835],
1854+
[0.24427, 0.60937, 0.99697],
1855+
[0.23874, 0.61931, 0.99485],
1856+
[0.23288, 0.62923, 0.99202],
1857+
[0.22676, 0.63913, 0.98851],
1858+
[0.22039, 0.64901, 0.98436],
1859+
[0.21382, 0.65886, 0.97959],
1860+
[0.20708, 0.66866, 0.97423],
1861+
[0.20021, 0.67842, 0.96833],
1862+
[0.19326, 0.68812, 0.96190],
1863+
[0.18625, 0.69775, 0.95498],
1864+
[0.17923, 0.70732, 0.94761],
1865+
[0.17223, 0.71680, 0.93981],
1866+
[0.16529, 0.72620, 0.93161],
1867+
[0.15844, 0.73551, 0.92305],
1868+
[0.15173, 0.74472, 0.91416],
1869+
[0.14519, 0.75381, 0.90496],
1870+
[0.13886, 0.76279, 0.89550],
1871+
[0.13278, 0.77165, 0.88580],
1872+
[0.12698, 0.78037, 0.87590],
1873+
[0.12151, 0.78896, 0.86581],
1874+
[0.11639, 0.79740, 0.85559],
1875+
[0.11167, 0.80569, 0.84525],
1876+
[0.10738, 0.81381, 0.83484],
1877+
[0.10357, 0.82177, 0.82437],
1878+
[0.10026, 0.82955, 0.81389],
1879+
[0.09750, 0.83714, 0.80342],
1880+
[0.09532, 0.84455, 0.79299],
1881+
[0.09377, 0.85175, 0.78264],
1882+
[0.09287, 0.85875, 0.77240],
1883+
[0.09267, 0.86554, 0.76230],
1884+
[0.09320, 0.87211, 0.75237],
1885+
[0.09451, 0.87844, 0.74265],
1886+
[0.09662, 0.88454, 0.73316],
1887+
[0.09958, 0.89040, 0.72393],
1888+
[0.10342, 0.89600, 0.71500],
1889+
[0.10815, 0.90142, 0.70599],
1890+
[0.11374, 0.90673, 0.69651],
1891+
[0.12014, 0.91193, 0.68660],
1892+
[0.12733, 0.91701, 0.67627],
1893+
[0.13526, 0.92197, 0.66556],
1894+
[0.14391, 0.92680, 0.65448],
1895+
[0.15323, 0.93151, 0.64308],
1896+
[0.16319, 0.93609, 0.63137],
1897+
[0.17377, 0.94053, 0.61938],
1898+
[0.18491, 0.94484, 0.60713],
1899+
[0.19659, 0.94901, 0.59466],
1900+
[0.20877, 0.95304, 0.58199],
1901+
[0.22142, 0.95692, 0.56914],
1902+
[0.23449, 0.96065, 0.55614],
1903+
[0.24797, 0.96423, 0.54303],
1904+
[0.26180, 0.96765, 0.52981],
1905+
[0.27597, 0.97092, 0.51653],
1906+
[0.29042, 0.97403, 0.50321],
1907+
[0.30513, 0.97697, 0.48987],
1908+
[0.32006, 0.97974, 0.47654],
1909+
[0.33517, 0.98234, 0.46325],
1910+
[0.35043, 0.98477, 0.45002],
1911+
[0.36581, 0.98702, 0.43688],
1912+
[0.38127, 0.98909, 0.42386],
1913+
[0.39678, 0.99098, 0.41098],
1914+
[0.41229, 0.99268, 0.39826],
1915+
[0.42778, 0.99419, 0.38575],
1916+
[0.44321, 0.99551, 0.37345],
1917+
[0.45854, 0.99663, 0.36140],
1918+
[0.47375, 0.99755, 0.34963],
1919+
[0.48879, 0.99828, 0.33816],
1920+
[0.50362, 0.99879, 0.32701],
1921+
[0.51822, 0.99910, 0.31622],
1922+
[0.53255, 0.99919, 0.30581],
1923+
[0.54658, 0.99907, 0.29581],
1924+
[0.56026, 0.99873, 0.28623],
1925+
[0.57357, 0.99817, 0.27712],
1926+
[0.58646, 0.99739, 0.26849],
1927+
[0.59891, 0.99638, 0.26038],
1928+
[0.61088, 0.99514, 0.25280],
1929+
[0.62233, 0.99366, 0.24579],
1930+
[0.63323, 0.99195, 0.23937],
1931+
[0.64362, 0.98999, 0.23356],
1932+
[0.65394, 0.98775, 0.22835],
1933+
[0.66428, 0.98524, 0.22370],
1934+
[0.67462, 0.98246, 0.21960],
1935+
[0.68494, 0.97941, 0.21602],
1936+
[0.69525, 0.97610, 0.21294],
1937+
[0.70553, 0.97255, 0.21032],
1938+
[0.71577, 0.96875, 0.20815],
1939+
[0.72596, 0.96470, 0.20640],
1940+
[0.73610, 0.96043, 0.20504],
1941+
[0.74617, 0.95593, 0.20406],
1942+
[0.75617, 0.95121, 0.20343],
1943+
[0.76608, 0.94627, 0.20311],
1944+
[0.77591, 0.94113, 0.20310],
1945+
[0.78563, 0.93579, 0.20336],
1946+
[0.79524, 0.93025, 0.20386],
1947+
[0.80473, 0.92452, 0.20459],
1948+
[0.81410, 0.91861, 0.20552],
1949+
[0.82333, 0.91253, 0.20663],
1950+
[0.83241, 0.90627, 0.20788],
1951+
[0.84133, 0.89986, 0.20926],
1952+
[0.85010, 0.89328, 0.21074],
1953+
[0.85868, 0.88655, 0.21230],
1954+
[0.86709, 0.87968, 0.21391],
1955+
[0.87530, 0.87267, 0.21555],
1956+
[0.88331, 0.86553, 0.21719],
1957+
[0.89112, 0.85826, 0.21880],
1958+
[0.89870, 0.85087, 0.22038],
1959+
[0.90605, 0.84337, 0.22188],
1960+
[0.91317, 0.83576, 0.22328],
1961+
[0.92004, 0.82806, 0.22456],
1962+
[0.92666, 0.82025, 0.22570],
1963+
[0.93301, 0.81236, 0.22667],
1964+
[0.93909, 0.80439, 0.22744],
1965+
[0.94489, 0.79634, 0.22800],
1966+
[0.95039, 0.78823, 0.22831],
1967+
[0.95560, 0.78005, 0.22836],
1968+
[0.96049, 0.77181, 0.22811],
1969+
[0.96507, 0.76352, 0.22754],
1970+
[0.96931, 0.75519, 0.22663],
1971+
[0.97323, 0.74682, 0.22536],
1972+
[0.97679, 0.73842, 0.22369],
1973+
[0.98000, 0.73000, 0.22161],
1974+
[0.98289, 0.72140, 0.21918],
1975+
[0.98549, 0.71250, 0.21650],
1976+
[0.98781, 0.70330, 0.21358],
1977+
[0.98986, 0.69382, 0.21043],
1978+
[0.99163, 0.68408, 0.20706],
1979+
[0.99314, 0.67408, 0.20348],
1980+
[0.99438, 0.66386, 0.19971],
1981+
[0.99535, 0.65341, 0.19577],
1982+
[0.99607, 0.64277, 0.19165],
1983+
[0.99654, 0.63193, 0.18738],
1984+
[0.99675, 0.62093, 0.18297],
1985+
[0.99672, 0.60977, 0.17842],
1986+
[0.99644, 0.59846, 0.17376],
1987+
[0.99593, 0.58703, 0.16899],
1988+
[0.99517, 0.57549, 0.16412],
1989+
[0.99419, 0.56386, 0.15918],
1990+
[0.99297, 0.55214, 0.15417],
1991+
[0.99153, 0.54036, 0.14910],
1992+
[0.98987, 0.52854, 0.14398],
1993+
[0.98799, 0.51667, 0.13883],
1994+
[0.98590, 0.50479, 0.13367],
1995+
[0.98360, 0.49291, 0.12849],
1996+
[0.98108, 0.48104, 0.12332],
1997+
[0.97837, 0.46920, 0.11817],
1998+
[0.97545, 0.45740, 0.11305],
1999+
[0.97234, 0.44565, 0.10797],
2000+
[0.96904, 0.43399, 0.10294],
2001+
[0.96555, 0.42241, 0.09798],
2002+
[0.96187, 0.41093, 0.09310],
2003+
[0.95801, 0.39958, 0.08831],
2004+
[0.95398, 0.38836, 0.08362],
2005+
[0.94977, 0.37729, 0.07905],
2006+
[0.94538, 0.36638, 0.07461],
2007+
[0.94084, 0.35566, 0.07031],
2008+
[0.93612, 0.34513, 0.06616],
2009+
[0.93125, 0.33482, 0.06218],
2010+
[0.92623, 0.32473, 0.05837],
2011+
[0.92105, 0.31489, 0.05475],
2012+
[0.91572, 0.30530, 0.05134],
2013+
[0.91024, 0.29599, 0.04814],
2014+
[0.90463, 0.28696, 0.04516],
2015+
[0.89888, 0.27824, 0.04243],
2016+
[0.89298, 0.26981, 0.03993],
2017+
[0.88691, 0.26152, 0.03753],
2018+
[0.88066, 0.25334, 0.03521],
2019+
[0.87422, 0.24526, 0.03297],
2020+
[0.86760, 0.23730, 0.03082],
2021+
[0.86079, 0.22945, 0.02875],
2022+
[0.85380, 0.22170, 0.02677],
2023+
[0.84662, 0.21407, 0.02487],
2024+
[0.83926, 0.20654, 0.02305],
2025+
[0.83172, 0.19912, 0.02131],
2026+
[0.82399, 0.19182, 0.01966],
2027+
[0.81608, 0.18462, 0.01809],
2028+
[0.80799, 0.17753, 0.01660],
2029+
[0.79971, 0.17055, 0.01520],
2030+
[0.79125, 0.16368, 0.01387],
2031+
[0.78260, 0.15693, 0.01264],
2032+
[0.77377, 0.15028, 0.01148],
2033+
[0.76476, 0.14374, 0.01041],
2034+
[0.75556, 0.13731, 0.00942],
2035+
[0.74617, 0.13098, 0.00851],
2036+
[0.73661, 0.12477, 0.00769],
2037+
[0.72686, 0.11867, 0.00695],
2038+
[0.71692, 0.11268, 0.00629],
2039+
[0.70680, 0.10680, 0.00571],
2040+
[0.69650, 0.10102, 0.00522],
2041+
[0.68602, 0.09536, 0.00481],
2042+
[0.67535, 0.08980, 0.00449],
2043+
[0.66449, 0.08436, 0.00424],
2044+
[0.65345, 0.07902, 0.00408],
2045+
[0.64223, 0.07380, 0.00401],
2046+
[0.63082, 0.06868, 0.00401],
2047+
[0.61923, 0.06367, 0.00410],
2048+
[0.60746, 0.05878, 0.00427],
2049+
[0.59550, 0.05399, 0.00453],
2050+
[0.58336, 0.04931, 0.00486],
2051+
[0.57103, 0.04474, 0.00529],
2052+
[0.55852, 0.04028, 0.00579],
2053+
[0.54583, 0.03593, 0.00638],
2054+
[0.53295, 0.03169, 0.00705],
2055+
[0.51989, 0.02756, 0.00780],
2056+
[0.50664, 0.02354, 0.00863],
2057+
[0.49321, 0.01963, 0.00955],
2058+
[0.47960, 0.01583, 0.01055]]
2059+
18032060

18042061
cmaps = {
18052062
name: ListedColormap(data, name=name) for name, data in [
@@ -1810,4 +2067,5 @@
18102067
('cividis', _cividis_data),
18112068
('twilight', _twilight_data),
18122069
('twilight_shifted', _twilight_shifted_data),
2070+
('turbo', _turbo_data),
18132071
]}

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,9 @@ def colormaps():
19151915
originally from the Neuroimaging in Python project
19161916
terrain mapmaker's colors, blue-green-yellow-brown-white,
19171917
originally from IGOR Pro
1918+
turbo Spectral map (purple-blue-green-yellow-orange-red) with
1919+
a bright center and darker endpoints. A smoother
1920+
alternative to jet.
19181921
============= =======================================================
19191922
19201923
The following colormaps are redundant and may be removed in future

tutorials/colors/colormaps.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@
179179
# gist_earth and terrain. CMRmap was created to convert well to
180180
# grayscale, though it does appear to have some small kinks in
181181
# :math:`L^*`. cubehelix was created to vary smoothly in both lightness
182-
# and hue, but appears to have a small hump in the green hue area.
182+
# and hue, but appears to have a small hump in the green hue area. turbo
183+
# was created to display depth and disparity data.
183184
#
184185
# The often-used jet colormap is included in this set of colormaps. We can see
185186
# that the :math:`L^*` values vary widely throughout the colormap, making it a
186187
# poor choice for representing data for viewers to see perceptually. See an
187-
# extension on this idea at [mycarta-jet]_.
188+
# extension on this idea at [mycarta-jet]_ and [turbo]_.
188189

189190
cmaps['Miscellaneous'] = [
190191
'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
191192
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',
192-
'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar']
193+
'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',
194+
'gist_ncar']
193195

194196
###############################################################################
195197
# .. _color-colormaps_reference:
@@ -348,8 +350,8 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
348350
# overlaid, labeled contours could help differentiate between one side of the
349351
# colormap vs. the other since color cannot be used once a plot is printed to
350352
# grayscale. Many of the Qualitative and Miscellaneous colormaps, such as
351-
# Accent, hsv, and jet, change from darker to lighter and back to darker gray
352-
# throughout the colormap. This would make it impossible for a viewer to
353+
# Accent, hsv, jet and turbo, change from darker to lighter and back to darker
354+
# grey throughout the colormap. This would make it impossible for a viewer to
353355
# interpret the information in a plot once it is printed in grayscale.
354356

355357
mpl.rcParams.update({'font.size': 14})
@@ -422,3 +424,4 @@ def plot_color_gradients(cmap_category, cmap_list):
422424
# .. [colorblindness] http://www.color-blindness.com/
423425
# .. [IBM] https://doi.org/10.1109/VISUAL.1995.480803
424426
# .. [palettable] https://jiffyclub.github.io/palettable/
427+
# .. [turbo] https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html

0 commit comments

Comments
 (0)