# complicated color function and color bar legend (summary of the results from previous relevant posts)

At first let me apologize. I should have read the policies of this forum before attempting a post. I was more accustomed to a moderated forum like MathGroup than such an active one like the StackExchange. Let me also thank from this position the following people that answering in my previous questions. Szabolcs kguler eldo Chenminqi

I really hope that I did not forget anyone! So in order to say a thank to these people and summarize for future reference the results I made the current post. The codes are based to replies I recieved. I wish that this will make up for any incovenience I caused:-)!

Let me state the problem now.

I have the following list of parametric equations (of an ellipsoid)

lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};


I also have the following functions of (u,v)

dam = 3*Sqrt[2]*Sqrt[(Cos[u]^2*(409 - 391*Cos[2*u] + 1800*Cot[v]^2))/(109 -
91*Cos[2*u] + 450*Cot[v]^2)^2];


I want a parametric plot of lst according to the values of dam.

I found the maximum value that dam can take.

Cases[Flatten[Table[{u, v, N[dam]}, {u, 0, 2*Pi, Pi/10}, {v, 0, Pi,
Pi/10}], 1], {a_, b_, c_ /; c > 1}]

FindMaximum[dam, {{u, Pi/10}, {v, Pi/2}}, WorkingPrecision -> 30]
maxDam = %[[1]]


Next, I define the color function

colFun = Function[{u, v},
Evaluate@Hue[Rescale[FullSimplify@dam, {0, maxDam}]]];


And now the plots.

g1 = ParametricPlot3D[lst, {u, 0, 2 π}, {v, 0, π}, Mesh -> False,
ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,
PlotPoints -> 100, ImageSize -> 800, ViewPoint -> {2, 2, 1}];

g2 = Plot3D[dam, {u, 0, 2 Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> colFun, ColorFunctionScaling -> False,
PlotRange -> All, PlotPoints -> 100, ImageSize -> 400];

Row[{Show[g1, ImageSize -> Large], Show[g2, ImageSize -> Medium]}]


At this point I have one question. See the extremities of the ellipsoid. There, after the purple color, comes the red and again (it seems to me) purple. Can anyone figure out what is going on?

Now, regarding the color bar.

{min, max} = {0, maxDam};
ParametricPlot3D[lst, {u, 0, 2 π}, {v, 0, π}, Mesh -> False,
ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,
PlotPoints -> 100, ImageSize -> 800,
PlotLegends ->
BarLegend[{Hue, {min, max}}, ColorFunctionScaling -> True]]


I want now to see a different color scheme.

I tried

coldata = ColorData["Gradients"];

col = Table[{i, coldata[[i]], ColorData[coldata[[i]]]}, {i, 51}];

Table[{min, max} = {0, maxDam};
lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};
colFun =
Function[{u, v}, Evaluate@col[[i, 3]][Rescale[dam, {0, maxDam}]]];
ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,
ImageSize -> 800,
PlotLegends -> BarLegend[{col[[i, 3]], {min, max}}]], {i, 51}]


Still, not satisfying with the coloring I tried the following function which I found here

http://stackoverflow.com/questions/5753508/custom-colorfunction-colordata-in-arrayplot-and-similar-functions

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 <= maxDam

{min, max} = {0, maxDam};
lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};
colFun = Function[{u, v}, Evaluate@jet[Rescale[dam, {0, maxDam}]]];
h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> (colFun[#4, #5] &), PlotPoints -> 100,
ColorFunctionScaling -> False, ImageSize -> 800,
PlotLegends -> BarLegend[{jet[#] &, {min, max}}]]


Now, the coloring scheme is great. But again it appears to exist the above mentioned problem with the extremities color rendering.

Last but not least, is it possible to make a function like jet above according to combination of colors {green, yellow, orange, blue, red}?

Dimitris

-