I want to replicate the color scheme colormap/hot from $\LaTeX$ PGF's package pgfplots. The color scheme colormap/hot can be found on p. 189 in the manual. It is defined by

colormap={hot}{color(0cm)=(blue); color(1cm)=(yellow); color(2cm)=(orange); color(3cm)=(red)}

The named colors are from the $\LaTeX$ package xcolor, the manual has a table of named base colors in section 4.1 and additional information, if needed.

The relevant definitions fo the used colors are from the xcolor.sty file:


The RGB values are as expected. I think the different colors are blended in a linear fashion.

I want to have a new color scheme, which replicates the above mentioned colormap. If this is not possible, an existing color scheme can be modified. I tried this myself, but could not get a working ColorDataFunction object. With the ColorBar package I was not able to define the color scheme manually, without having to drag control points in the form.

I got as far as this:

ColorData["TemperatureMap"] // FullForm
(* ColorDataFunction["TemperatureMap","Gradients",List[0,1],Function[Blend["TemperatureMap",Slot[1]]]] *)

colfunc=ColorDataFunction["PGFhot", "Gradients", List[0, 1], Blend[Transpose[{{0, 1/3, 2/3, 1}, {Blue, Yellow, Orange, Red}}], #1] &]

But colfunc is apparently no ColorDataFunction.

In the end, I want to use the new color scheme like this:

Plot[x, {x, 0, 1}, 
  ColorFunction -> "Rainbow", 
  PlotLegends -> BarLegend[{ColorData["Rainbow"], {0, 1}}]

1 Answer 1

    colfunc = Blend[Transpose[{{0, 1/3, 2/3, 1}, {Blue, Yellow, Orange, Red}}], #]&

    Plot[x, {x, 0, 1}, ColorFunction -> colfunc, PlotLegends -> BarLegend[{colfunc, {0, 1}}]]

enter image description here

This is how to simply use a custom color scheme. If you're wanting to have it integrated into MMA in a manner similar to the built in ColorDataFunctions then this is a good question to read through.

  • $\begingroup$ Thank you. I also tried you definition of colfunc, but I did not name it and tried to use it as a pure function. But I forgot the pair of curly brackets so it would not work. $\endgroup$ Feb 12, 2016 at 17:37
  • $\begingroup$ Due to the equal spacing, Blend[{Blue, Yellow, Orange, Red}, #] & will also work. $\endgroup$ Mar 24, 2016 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.