Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to create a plot of a surface that is yellow above the xy-plane (z>0), but blue below (z<0). My first attempt was to use ColorFunction->Function[{x,y,z},If[z>0,Hue[0.2],Hue[0.6]], but this only gave me a solid yellow paraboloid. I also tried defining a custom ColorFunction scheme with cf=Piecewise[{{Yellow,0<#3<30},{Blue,-70<#3<0}}]&; and ColorFunction->cf to the same result. Finally, I tried the following based on another thread (Discrete coloring in Plots):

ParametricPlot3D[{x,y,x^2+y^2-5},{y,-3,3},{x,-3,3},PlotStyle->Opacity[.8],ColorFunction->(If[#3>0,Yellow,Blue]&),Mesh->False,BoundaryStyle->{Black,Thickness[.01]}]

Every time, I end up with this:

yellow paraboloid

Any help you can offer would be greatly appreciated.

share|improve this question
1  
Try ColorFunctionScaling -> False? and a large value for PlotPoints , e.g., PlotPoints -> 150. –  kguler Jul 19 at 1:40
    
Thank you! Do you know how to limit the artifacts near z=0 so that it is more of a discrete color change? PlotPoints->100 works, but it slows everything down. i.imgur.com/tFh63XY.jpg –  WorfSonOfMogh Jul 19 at 1:42
    
Worf, i don't know of any way to get rid of the jagged ring. A work-around is to "hide" it under a mesh at 0 using the combination of options MeshFunctions -> {#3 &}, Mesh -> {{0}}, MeshStyle -> Directive[Blue, Opacity[.8], Thickness[.01]]. ... Just learned myself the best way: Michael's approach using MeshShading :) –  kguler Jul 19 at 2:01

1 Answer 1

I would use MeshShading, as shown in the documentation for ParametricPlot3D:

ParametricPlot3D[{x, y, x^2 + y^2 - 5}, {y, -3, 3}, {x, -3, 3}, 
 MeshShading -> {Directive[Opacity[.8], Blue], 
   Directive[Opacity[.8], Yellow]}, Mesh -> {{0}}, 
 MeshFunctions -> {#3 &}, BoundaryStyle -> {Black, Thickness[.01]}, 
 Lighting -> "Neutral"]

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.