Before all, I have read this question and others but it doesn't help me, I thought I understand the problem but actually not (see my post)
Controlling ColorFunctionScaling
I want to do a very simple thing which again looks very complicated on mathematica.
I have spherical datas (function depending on $\theta$ and $\phi$ that I want to plot using a color scale on a sphere).
However, the color scaling is not good : not all the colors available are used (if I use a TemperatureMap, it will only use the high temperature colors for example).
I know it is a problem of scaling, I tried to modify it but I'm stuck and I'm not sure to really understand the thing.
Here is my code :
The function I use for my example (my functions are more complicated than just a cos(theta)), so please don't consider "special properties" of cos to answer :
f[Theta_] := Cos[Theta]
Thus, what I expect : The plot takes a value of theta, it computes cos[theta]. It does it for all values of theta. Then, in the end, it will affect the blue color to the lowest value, the red color to the highest. And all the intermediates colors for the intermediates values. Of course the law of assigning the colors is a cos(theta) law
Because what I don't get in the answer given is that the function cos[theta] never appears in the call of the spherical plot3D, they ask for a dependance in theta for the color from what I understood. I agree that theta and cos[theta] are both increasing functions here, but it is not the same law so the variation of colors shouldn't be the same. So, cos[theta] should appear in the call of sphericalplot3D as it is the dependance I want. We could imagine $f$ beeing a complicated, non monotonous function of theta in a more general case for example.
The first code and the result :
SphericalPlot3D[1, {Theta, 0, \[Pi]}, {Phi, 0, 2*\[Pi]},
ColorFunction ->
Function[{x, y, z, Theta, Phi},
ColorData["TemperatureMap"][f[Theta]]], Mesh -> True,
Boxed -> False, PlotStyle -> Directive[Opacity[.8]],
ColorFunctionScaling -> True]
I thought that because of the option ColorFunctionScaling True, mathematica would do the work to rescale my function between 0 and 1 before applying the color on it. But it doesnt work as I dont have any blue colors on my plot...
Anyway, I tried to do the job for mathematica by rescaling my data directly.
SphericalPlot3D[1, {Theta, 0, \[Pi]}, {Phi, 0, 2*\[Pi]},
ColorFunction ->
Function[{x, y, z, Theta, Phi},
ColorData["TemperatureMap"][(f[Theta] + 1)/2]], Mesh -> True,
Boxed -> False, PlotStyle -> Directive[Opacity[.8]],
ColorFunctionScaling -> True]
$(f[Theta] + 1)/2 = (Cos[Theta]+1)/2$, thus it belongs to $[0;1]$.
And of course it doesnt work either.
Where is the problem ? I am getting crazy it should be simple to solve it.
In summary : Here, I expect my graphs to have colors going from blue to red. However as you can see not all of the color are used.