Re: To color surfaces using z values with ContourPlot3D
- To: mathgroup at smc.vnet.net
- Subject: [mg23912] Re: To color surfaces using z values with ContourPlot3D
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 16 Jun 2000 00:56:52 -0400 (EDT)
- References: <8i9ov0$2dm@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Valeria, We can add styling instructions to the polygons "from the outside": eq = 81*(x^3 + y^3 + z^3) - 189*(x^2*y + x^2*z + y^2*x + y^2*z + z^2*x + z^2*y) + 54*x*y*z + 126*(x*y + x*z + y*z) - 9*(x^2 + y^2 + z^2) - 9*(x + y + z) + 1; sup = ContourPlot3D[eq, {x, -1, 3/2}, {y, -1, 3/2}, {z, -1, 3/2}, PlotPoints -> {5, 7}, Axes -> True, ViewPoint -> {0.056, -3.382, -0.076}, ContourStyle -> {EdgeForm[GrayLevel[0.6]]}, Lighting -> False] Define acolor function. cf[z_] := Hue[(z + 1)/3.5]; Use cf to give styles to the polygons. sup2 = sup /.{p_Polygon :> {cf[(Plus @@ (p[[1, All, 3]]))/Length[p[[1]]]], p} } Show the result Show[sup2, AxesLabel -> {x, y, z}] You might like to look at the furface in simulated lighting with RealTime3D, it can then be grabbed by the pointer and rotated << RealTime3D` ContourPlot3D[eq, {x, -1, 3/2}, {y, -1, 3/2}, {z, -1, 3/2}, PlotPoints -> {5, 7}, Axes -> True, ViewPoint -> {0.056, -3.382, -0.076}, ContourStyle -> {EdgeForm[]}] << Default3D` -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Valeria Olivati" <olivaleNNN at tin.it> wrote in message news:8i9ov0$2dm at smc.vnet.net... > Hallo eveybody, > > I'm a student of Mathematics at University of Pavia, Italy. > > I start using Mathematica 4 two months ago, and I need to plot a cubic > function and color it without using LightSources. I use ContourPlot3D to > plot the function but I don't know how to color the surface using the z > values, as you can do using Plot3D and ColorFunction->Hue. > I cannot use Plot3D because the function is quite complicated: > > eq = 81*(x^3 + y^3 + z^3) - 189*(x^2*y + x^2*z + y^2*x + y^2*z + z^2*x + > z^2*y) + 54*x*y*z + 126*(x*y + x*z + y*z) - 9*(x^2 + y^2 + z^2) - 9*(x+y+z) > + 1 > > Now I plot this funtion in this way: > > sup = ContourPlot3D[eq, {x, -1, 3/2}, {y, -1, 3/2}, {z, -1, 3/2}, > PlotPoints->{5,7}, Axes->True, ViewPoint->{0.056, -3.382, -0.076}, > ContourStyle->{Hue[1], EdgeForm[GrayLevel[0.6]]}, Lighitng->False] > > but with only one color It's not a clear shape. > If I use the following LightSources instead of ConturStyle > > LightSources->{{{0,0,0.7}, RGBColor[0,1,0]}, {{1,0,1}, RGBColor[1,1,0]}, > {{-1,0,1}, RGBColor[0,0,1]}, {{-1,0,0}, GrayLevel[1]}} > > I don't like the colors I obtain, they are not linked to the surface but > they are the best LightSources I found after a big number of changes. Of > course my problem with LightSources is that I haven't understood how they > work.... > > I hope someone has suggestions for me > Thanks a lot > > Best Regards > > Olivati Valeria > > >