0
$\begingroup$

I have a 3D data set and would like to color the ListPlot3D but have all the values equal to zero show up as a single colour. For example, having the non-zero points here stay the same, but the surrounding areas to be gray, for example. Thank you in advance for any advice.

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ Change the ColorFunction to be something like With[{cf=ColorData["M10DefaultDensityGradient"]}, If[#==0., GrayLevel[.8], cf[#]]&] $\endgroup$
    – b3m2a1
    Mar 2 '20 at 6:41
  • 1
    $\begingroup$ add the options PlotRange -> {0, All} and ClippingStyle -> Gray? $\endgroup$
    – kglr
    Mar 2 '20 at 6:48
  • 1
    $\begingroup$ @kglr that's just what I was looking for, thank you! $\endgroup$
    – j.foobles
    Mar 2 '20 at 11:14
  • $\begingroup$ j.foobles, you are welcome. I posted the comment as an answer. $\endgroup$
    – kglr
    Mar 2 '20 at 11:24
2
$\begingroup$
data = Table[Sin[j^2 + i], {i, 0, Pi, 0.1}, {j, 0, Pi, 0.1}]; 

You can use the options PlotRange -> {0, All} and ClippingStyle -> Gray:

ListPlot3D[data, 
 ColorFunction -> "Rainbow", Mesh -> None,
 PlotRange -> {0, All},  
 ClippingStyle -> Gray]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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