# How to recreate the gnuplot color scheme "AFM Hot" in Mathematica?

I'm trying to build an 3D AFM image from raw data with Mathematica. So how do I recreate the "AFM hot" color scheme? I've tried "SolarColors" and "RustTones", but they don't quite do the job.

"AFM hot" looks like this (I took this picture from here):

Test function:

f[x_, y_] := 0.1 + (1 - (x - 2)^2) (1 - (y - 2)^2) So these gnuplot color maps are a little bit more complicated than can be easily achieved by Blend (although you can do some cool stuff with Blend).

If you look at this page you can see that they specify a particular mapping function for the three different RGB components as a function of the scaling parameter x.

AFMHot uses functions 33, 34, and 35, which correspond to 2 x, 2 x - 0.5, and 2x - 1.0, where x goes from 0 to 1

afmHot = RGBColor[2 #, 2 # - .5, 2 # - 1] &;

Plot3D[0.1 + (1 - (x - 2)^2) (1 - (y - 2)^2), {x, 1, 3}, {y, 1, 3},
ColorFunction -> Function[{x, y, z}, afmHot[z]] ]
DensityPlot[
0.1 + (1 - (x - 2)^2) (1 - (y - 2)^2), {x, 1, 3}, {y, 1, 3},
ColorFunction -> afmHot , PlotLegends -> Automatic] You can do the rest of the color maps via

traditional = RGBColor[Sqrt[#], #^3, Sin[2 π #]] &;
greenRedViolet = RGBColor[#, Abs[# - .5], #^4] &;
ocean = RGBColor[3 # - 2, Abs[(3 # - 1)/2], #] &;
hot = RGBColor[3 #, 3 # - 1, 3 # - 2] &;
rainbow = RGBColor[Abs[2 # - .5], Sin[π #], Cos[π/2 #]] &;
afmHot = RGBColor[2 #, 2 # - .5, 2 # - 1] &;

ocean, hot, rainbow, afmHot} // Column • The component functions are (piecewise) linear, so Blend[] can be used here. See my answer. Mar 24 '16 at 13:11
• Right on - but could you do the nonlinear ones, the ones that call on Sqrt and trig functions? Also, what is meant by the notation in component 32? Mar 24 '16 at 13:20
• Of course, you can't use Blend[] on those colors. ;) I'm not sure about those semicolons, I've looked through the manual and all I can find was that they're just separators. Mar 24 '16 at 13:49
• Okay, it's apparently a piecewise function. Try this: f303132[x_] := RGBColor[Clip[25 x/8 - 25/32 , {0, 1}], Clip[2 x - 21/25, {0, 1}], Piecewise[{{4 x, 0 <= x < 1/4}, {1, 1/4 <= x < 21/50}, {46/25 - 2 x, 21/50 <= x < 23/25}, {(25 x - 23)/2, 23/25 <= x <= 1}}]] Mar 24 '16 at 14:06

The gradient of interest here is actually a Gnuplot color scheme. From here we find that "AFM hot" corresponds to using components 34, 35, and 36 (with suitable clipping). Thus,

afmhot[x_] /; 0 <= x <= 1 :=
RGBColor[Min[2 x, 1], Min[Max[0, 2 x - 1/2], 1], Max[0, 2 x - 1]]


or, using Blend[],

afmhot[x_] /; 0 <= x <= 1 :=
Blend[{Black, RGBColor[1/2, 0, 0], RGBColor[1, 1/2, 0],
RGBColor[1, 1, 1/2], White}, x]


Test:

LinearGradientImage[afmhot, {300, 30}] Plot3D[1/10 + (1 - (x - 2)^2) (1 - (y - 2)^2), {x, 1, 3}, {y, 1, 3},
ColorFunction -> (afmhot[#3] &)] As Vitaliy pointed out, you can always define your own colour scheme.

clfun = Blend[{Black, Red, Yellow, White}, #] &; (*color scheme*)
Plot3D[0.1 + (1 - (x - 2)^2) (1 - (y - 2)^2), {x, 1, 3}, {y, 1, 3},
ColorFunction -> Function[{x, y, z}, clfun[z]]] RedTempX[x_] := RGBColor[Min[{1, 4x/3}], Max[{0, 2x-1}], Max[{0, 4x-3}]]

 Plot3D[0.1 + (1 - (x - 2)^2) (1 - (y - 2)^2), {x, 1, 3}, {y, 1, 3}, 