# How to set fixed colorbar values for jet colormap?

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}}]]


the data range is not correct

• ColorFunctionScaling -> True ?
– Syed
Jun 6, 2022 at 7:37
• This can only change the data range for the barlegend but the density plot range will not chang Jun 6, 2022 at 7:49
• You already knew what to do in your first snippet; making the replacement with my 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}}]] Jun 6, 2022 at 15:34

DensityPlot[Sin[x]*Cos[y]*0.3, {x, -1, 1}, {y, -1, 1},