I am trying to plot some Zernike polynomials, but I want all of them to be plotted by using the same colour scale from -1 to +1 (i.e. the range of these polynomials). I am using the following code:
DensityPlot[
ZernikeR[n, m, Norm[{x, y}]] Cos[m ArcTan[x, y]], {x, -1, 1}, {y, -1,1}
, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}
, ColorFunction -> (Hue[2 (1 - #1)/3] &)
, PlotPoints -> 200
, PlotLegends -> Automatic
, RegionFunction -> Function[{x, y, z}, -1 < x^2 + y^2 < 1]
]
I get what I want with some polynomials, e.g. when m=0 and n=2:
and not with others, e.g. when m=0 and n=4:
where the colour range goes down to -0.5 and not to -1. I want all polynomials to be coloured with a scale from -1 to 1, from blue to red. I haven't found a way to fix this. What am I missing? Thanks.
ColorFunctionScaling
andColorFunction
. $\endgroup$ColorFunctionScaling -> False
will prevent scaling but2 (1 - #1)/3 &@Interval[{-1, 1}]
gives:Interval[{0, 4/3}]
which can be missleading whenHue
is applied ( {0,1} base domain). What exactly do you want to achieve, how your manual rescaling is related to the problem and are you only concerned about colors or the range in the bar legend aswell? $\endgroup$