While trying to answer this question I found out "weird" behavior of ColorFunction
Plot3D[x y, {x, -10, 10}, {y, -10, 10}, PlotRange -> Full,
ColorFunction -> Function[{x, y, z}, Hue@(x y)]]
gives incorrect colors
the virtually identical code (from naive point of view)
Plot3D[x y, {x, -10, 10}, {y, -10, 10}, PlotRange -> Full,
ColorFunction -> Function[{x, y, z}, Hue@z]]
gives correct plot
Also if you disable ColorFunctionScaling
as many posts (e.g. this) suggest
Plot3D[x y, {x, -10, 10}, {y, -10, 10}, PlotRange -> Full,
ColorFunction -> Function[{x, y, z}, Hue@(x y)],
ColorFunctionScaling -> False]
the colors are really messed up
So the question - why are the first two plots different? A bug?
I'm using Mathematica 11.1 on Linux.
Answer
As the documentation on ColorFunctionScaling
says,
ColorFunctionScaling is an option for graphics functions that specifies whether arguments supplied to a color function should be scaled to lie between 0 and 1.
In the first plot, $x$ and $y$ are both scaled to the range $[0,1]$. This means that the ColorFunction
does not receive $x$ and $y$, but rather $(x+10)/20$ and $(y+10)/20$, and the color is then the hue of $(x+10)(y+10)/400$.
In the second plot, $z$ is scaled to the range $[0,1]$. This means that the ColorFunction
does not receive $z$, but rather $(z+100)/200$ as the third argument.
In the third plot, the number of PlotPoints
is too small and thus you see Moiré effects.
Comments
Post a Comment