I want to use the jet color function in Mathematica, and the jet color function is defined as
jet[u_?NumericQ]:=Blend[{{0,RGBColor[0,0,9/16]},{1/9,Blue},{23/63,Cyan},{13/21,Yellow},{47/63,Orange},{55/63,Red},{1,RGBColor[1/2,0,0]}},u]/;0<=u<=1
which is from the question: Custom ColorFunction/ColorData in ArrayPlot (and similar functions)
When I use jet to plot, I found that Mathematica will automatically use the maximum and minimum as the data range, there are solutions to rescale the colordata for the default colormap in Mathematica, but I can't use these methods to set the range for jet colormap. Here is a minimum example: The default colormap's range could be set as
DensityPlot[Sin[x]*Cos[y], {x, -1, 1}, {y, -1, 1},
ColorFunction -> (ColorData["TemperatureMap",
Rescale[#, {-1, 1}]] &), ColorFunctionScaling -> False,
PlotLegends -> BarLegend[{Automatic, {-1, 1}}]]
and if I use jet colorfunction
DensityPlot[Sin[x]*Cos[y], {x, -1, 1}, {y, -1, 1},
ColorFunction -> jet, ColorFunctionScaling -> False,
PlotLegends -> BarLegend[{Automatic, {-1, 1}}]]
ColorFunctionScaling -> True
? $\endgroup$jet[]
function should have been straightforward:DensityPlot[Sin[x]*Cos[y], {x, -1, 1}, {y, -1, 1}, ColorFunction -> (jet[Rescale[#, {-1, 1}]] &), ColorFunctionScaling -> False, PlotLegends -> BarLegend[{Automatic, {-1, 1}}]]
$\endgroup$