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):


Every time, I end up with this:

yellow paraboloid

Any help you can offer would be greatly appreciated.

  • 1
    $\begingroup$ Try ColorFunctionScaling -> False? and a large value for PlotPoints , e.g., PlotPoints -> 150. $\endgroup$
    – kglr
    Commented Jul 19, 2014 at 1:40
  • $\begingroup$ 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 $\endgroup$ Commented Jul 19, 2014 at 1:42
  • $\begingroup$ 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 :) $\endgroup$
    – kglr
    Commented Jul 19, 2014 at 2:01

2 Answers 2


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

  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},
 PlotStyle -> Opacity[.8], Mesh -> None, BoundaryStyle -> {Black, Thickness[.01]},
 ColorFunction -> cf, ColorFunctionScaling -> False, 
 Exclusions -> {x^2 + y^2 == 5}, ExclusionsStyle -> Blue]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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