# Two discrete colors for surface with ParametricPlot3D

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:

• Try ColorFunctionScaling -> False? and a large value for PlotPoints , e.g., PlotPoints -> 150. – kglr Jul 19 '14 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 '14 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 :) – kglr Jul 19 '14 at 2:01

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},

1. Use your cf as the setting for ColorFunction and add the option ColorFunctionScaling -> False.
2. To get a sharp change from Blue to Yellow add the options Exclusions -> {x^2 + y^2 == 5} and ExclusionsStyle -> Blue.
ParametricPlot3D[{x, y, x^2 + y^2 - 5}, {y, -3, 3}, {x, -3, 3},