I am plotting Zernike-Polynomials like this:
---------
c4 = 1;
z4[rho_, theta_] := rho^2*Cos[2*theta]
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> "Rainbow"]
---------
To be able to compare the plot to measured data from an
interferometer, I would like to invert the Rainbow colouring, that is
red at the bottom and blue on top. However, I can't find to work this
out. Does anyone know how to do this?
Thank you,
Vladimir.
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> (ColorData["Rainbow"][1 - #3] &)]
does the job.
regards,
Maarten
ColorFunction->"Rainbow"
is shorthand for
ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][z]
where z is the value of the dependent variable scaled to be between 0
and 1. So, to invert the colors, flip the scale to z is scaled to be
between 1 and 0:
ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][1 - z]]
To learn more, look up ColorFunction, ColorData, ColorDataFunction,
and Color Schemes in the Doc Center.
Daniel
z4[rho_, theta_] := rho^2*Cos[2*theta]
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> (ColorData["Rainbow", 1 - #3] &)]
Vivek
However, on the RevolutionPlot3D page, Examples, Options, ColorFunction,
first example WRI does give the ordering of the parameters. These are:
{x, y, z, t, \[Theta], r}
I don't know exactly how you want to color the surface. Suppose you want to
color according to the z value and use the reverse gradient. Then you could
write:
c4 = 1;
z4[rho_, theta_] := rho^2 Cos[2 theta]
RevolutionPlot3D[c4 z4[rho, theta], {rho, 0, 1}, {theta, 0, 2 \[Pi]},
ColorFunction -> (ColorData["Rainbow"][1 - #3] &)]
You could also write this as:
RevolutionPlot3D[c4 z4[rho, theta], {rho, 0, 1}, {theta, 0, 2 \[Pi]},
ColorFunctionScaling -> False,
ColorFunction -> (ColorData["Rainbow"][Rescale[#3, {1, -1}]] &)]
Or as:
RevolutionPlot3D[c4 z4[rho, theta], {rho, 0, 1}, {theta, 0, 2 \[Pi]},
ColorFunctionScaling -> False,
ColorFunction -> (ColorData["Rainbow"][
Rescale[#3, {-1, 1}, {1, 0}]] &)]
The usefulness of that construction is if your wanted to write your own
color function as a function of the actual parameters. Then you could find
the minimum and maximum values over the surface and use Rescale to fit it to
a gradient, a reverse gradient or even a part of a gradient.
Notice also that in Version 7, if one uses a ColorFunction on various
surface plots, Mathematica uses Lighting -> "Neutral". This is nice because
the color of the lights won't overwhelm pastel colored surfaces.
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
This seems to do what you want:
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> (ColorData["Rainbow"][1 - #3] &)]
Regards,
Leonid
c4 = 1;
z4[rho_, theta_] := rho^2*Cos[2*theta];
min = -1 (* the minimun in your z axis*);
max = 1 (*...maximun ....*);
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> (ColorData["Rainbow"][(#3 - min)/(max - min)] &),
ColorFunctionScaling -> False]
----- Original Message -----
From: "Vladimir" <svetl...@yahoo.de>
To: <math...@smc.vnet.net>
Sent: Thursday, January 21, 2010 3:31 AM
Subject: How To invert ColorFunction
Bob Hanlon
---- Vladimir <svetl...@yahoo.de> wrote:
=============
what about
c4 = 1;
z4[rho_, theta_] := rho^2*Cos[2*theta]
RevolutionPlot3D[c4*z4[rho, theta], {rho, 0, 1}, {theta, 0, 2*Pi},
ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][1 - z]]]
?
Cheers
Patrick
I did look up ColorFunction in the Documentation Center, but didn't
work out that I could enter [1-z] as the second argument. Thank you
all so much, now it works perfectly.
Bye,
Vlad.