Function Repository Resource:

TurboColor

Source Notebook

Implementation of the Turbo color map

Contributed by: Julien Kluge

ResourceFunction["TurboColor"][q]

interpolates the Turbo color scheme along the parameter q in a range from 0 to 1. Values above 1 and below zero get clamped.

Details and Options

For more information about the color map, see here.
ResourceFunction["TurboColor"] uses interpolation of 256 distinct points in RGB colorspace as defined in the reference implementation.

Examples

Basic Examples (2) 

Evaluate the color map at a single point q=0.1 :

In[1]:=
ResourceFunction["TurboColor"][0.1]
Out[1]=

Use the color map as the ColorFunction for a DensityPlot:

In[2]:=
DensityPlot[Exp[-x^2 + y/3], {x, -3, 3}, {y, -2, 2}, PlotRange -> All,
  PlotPoints -> 100, PlotLegends -> Automatic,
 ColorFunction -> (ResourceFunction["TurboColor"][#] &)]
Out[2]=

Scope (1) 

TurboColor automatically threads over lists:

In[3]:=
ResourceFunction["TurboColor"][Range[0, 1, 1/30]]
Out[3]=

Applications (1) 

Use the Turbo color scheme in a DensityPlot:

In[4]:=
Plot3D[Sin[x]/(Sqrt[x] + 1)*Cos[y], {x, -3 Pi, 3 Pi}, {y, -Pi, 2 Pi}, PlotRange -> All, PlotLegends -> Automatic,
 ColorFunction -> (ResourceFunction["TurboColor"][#3] &)]
Out[4]=

Properties and Relations (1) 

Values below zero and above 1 get clamped:

In[5]:=
BarLegend[{ResourceFunction["TurboColor"][#] &, {-1, 2}}, LegendLayout -> "Row"]
Out[5]=

Possible Issues (1) 

TurboColor clamps values and thus needs ColorFunctionScaling to be True to use the whole value range:

In[6]:=
DensityPlot[Exp[-x^2 + y/3], {x, -3, 3}, {y, -2, 2}, PlotRange -> All,
  PlotPoints -> 100, PlotLegends -> Automatic, ColorFunctionScaling -> False,
 ColorFunction -> (ResourceFunction["TurboColor"][#] &)]
Out[6]=

Neat Examples (1) 

Rough simulation of the color map with normal vision, Protanopia, Tritanomaly, Achromatomaly and Achromatopsia color blindness:

In[7]:=
DensityPlot[Exp[-x^2 + y/3], {x, -3, 3}, {y, -2, 2}, PlotRange -> All,
    PlotPoints -> 100, PlotLabel -> #2,
   ColorFunction -> Function[
     q, (ResourceFunction["TurboColor"][q] /. RGBColor[r_, g_, b_] :> RGBColor[#1 . {r, g, b}])]] & @@@ {
  {IdentityMatrix[3], "Normal vision"},
  {{{0.57, 0.43, 0}, {0.56, 0.44, 0}, {0, 0.24, 0.76}}, "Protanopia"},
  {{{0.97, 0.3, 0}, {0, 0.73, 0.27}, {0, 0.18, 0.82}}, "Tritanomaly"},
  {{{0.62, 0.32, 0.06}, {0.16, 0.78, 0.06}, {0.16, 0.32, 0.52}}, "Achromatomaly"},
  {ConstantArray[{0.3, 0.59, 0.11}, 3], "Achromatopsia"}
  }
Out[7]=

Publisher

Julien Kluge

Version History

  • 1.0.0 – 16 April 2020

Source Metadata

Related Resources

Author Notes

Julien Kluge

Quantum Optical Metrology; Joint Lab Integrated Quantum Sensors

Department of Physics

Humboldt-Universität zu Berlin

(julien@physik.hu-berlin.de)

License Information