Re: Shading Functions

*To*: mathgroup at smc.vnet.net*Subject*: [mg14362] Re: [mg14293] Shading Functions*From*: Jurgen Tischer <jtischer at col2.telecom.com.co>*Date*: Thu, 15 Oct 1998 00:29:03 -0400*Organization*: Universidad del Valle*References*: <199810130521.BAA08517@smc.vnet.net.>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Des, if you use ColorFunction the values of your function are normalized by Mathematica to values between 0 and one. (See Help on ColorFunction, the line reads "The arguments provided for the function specified by ColorFunction are always in the range 0 to 1.") So you get other colors than in you self-made color function where Mathematica allows you to go cyclically around if you want. (Try p2=Plot3D[{Sin[x y], colorFun[3Sin[x y]]},{x,-1,1},{y,-2,2}, AxesLabel->{X,Y,Z}]; to see what happens.) Jurgen Des Penny wrote: > > Hi Folks: > > I'm having trouble invoking the shading function in one form. > > The following works ok: > > In[1]:= > p1=Plot3D[Sin[x y],{x,-1,1},{y,-2,2}, AxesLabel->{X,Y,Z}]; > > If we map the range of the plot into {0,0.8}, we will now be able to > color the heights of a plot so that the lowest points are red and the > highest points are Blue/Purple. > > In[2]:= > PlotRange[p1] > Out[2]= > {{-1.,1.},{-2.,2.},{-1.04461,1.04461}} > > In[3]:= > zrange=PlotRange[p1][[3]] > Out[3]= > {-1.04461,1.04461} > > The max and min values of Sin are {-1,1}, so this checks. > > We now want to map the heights, z, into the range {0,0.8}. Using the > linear map, c=a z+b we find c=0.40 z+0.40 will work. > > In[4]:= > (0.4 zrange+0.4) > Out[4]= > {-0.0178423,0.817842} > > If we now operate on each z value with Hue we will display this z value > in the correct color: > > In[5]:= > Clear[colorFun]; > colorFun[z_]:=Hue[0.4(z+1)] > > In[6]:= > p2=Plot3D[{Sin[x y], colorFun[Sin[x y]]},{x,-1,1},{y,-2,2}, > AxesLabel->{X,Y,Z}]; > > This works fine. > > However the following does not work correctly. I'm not sure why. > > In[7]:= > Show[p2, ColorFunction->colorFun]; > > I was under the impression that the above statement caused colorFun to > operate on the z values of the function. We should get the same plot > as the preceeding Plot3D but we don't. The output of the above clearly > shows that colorFun is operating, but not correctly. > > Can anyone help explain what's going on? > > Cheers, > > Des Penny

**References**:**Shading Functions***From:*Des Penny <penny@suu.edu>