Re: Q: Varying colors in Plot3D according to Height
- To: mathgroup at smc.vnet.net
- Subject: [mg55437] Re: Q: Varying colors in Plot3D according to Height
- From: yehuda ben-shimol <bsyehuda at gmail.com>
- Date: Wed, 23 Mar 2005 05:34:47 -0500 (EST)
- References: <200503220851.DAA23758@smc.vnet.net>
- Reply-to: yehuda ben-shimol <bsyehuda at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, Say that your function is called f of two parameters say, x and y. for the following example I will use f[x_,y_]:=2*Sin[x+y] You need to set the option ColorFunctionScaling->False and define your own ColorFunction look at the following example Plot3D[2Sin[x+y],{x,0,2\[Pi]},{y,0,2\[Pi]},ColorFunctionScaling->False, ColorFunction->(If[#<1,Hue[#],Hue[0]]&)] Notice that the areas with values below 1 will NOT be colored with the default colors, since you need to operate the ColorFunction on the unscaled values of your function. However the red areas are exactly what you needed. Since the Hue[] function is cyclic (i.e., Hue[x]==Hue[Mod[x,1]]) scaling is important for nice representation. In case you KNOW in advanced the maximal value of the function (call is maxF) then you may modify the code a little by Plot3D[2Sin[x+y],{x,0,2\[Pi]},{y,0,2\[Pi]},ColorFunctionScaling->False, ColorFunction->(If[#<1,Hue[#/maxF],Hue[0]]&)] But from some tests I made I do not really think this is important Regards yehuda On Tue, 22 Mar 2005 03:51:04 -0500 (EST), Mark Coleman <mark at markscoleman.com> wrote: > I am plotting a three-dimension function using Plot3D. I would like to > highlight the portion of the surface whose height exceeds 1.0 a > different color or hue than the portion of the surface below 1.0. My > attempts at using ColorFunction to do this have been less than > aesthetically pleasing, to say the least. Ideally, I'd like the portion > below 1.0 to retain the default Mathematica blue shading (I'm using > Mathematica ver 5.1.1 on a Mac OS X 10.3.8), and perhaps have the portion > above 1.0 to have a red shading. Any help would be greatly appreciated. > > Thanks, > > -Mark > >
- References:
- Q: Varying colors in Plot3D according to Height
- From: Mark Coleman <mark@markscoleman.com>
- Q: Varying colors in Plot3D according to Height