Shading Functions
- To: mathgroup at smc.vnet.net
- Subject: [mg14293] Shading Functions
- From: Des Penny <penny at suu.edu>
- Date: Tue, 13 Oct 1998 01:21:12 -0400
- Organization: Southern Utah University
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Shading Functions
- From: Jurgen Tischer <jtischer@col2.telecom.com.co>
- Re: Shading Functions