How can I exclude a region in a 3D plot?

I have done it for a Density plot, but for the 3D case, it seems difficult to exclude a region (with a certain relation between two main parameters). In fact, the 3D plot is for a relation in terms of "a" and "b", and each one of these parameters has a limitation. I want to denote the area of banned values of "a" and "b" (which is an inequality relation between these parameters) by a red boundary in the main 3D plot.

  • 2
    $\begingroup$ It is easier to help, if you provide code with your own attempt as a starting point and an example figure illustrating what you want to achieve. $\endgroup$
    – Johu
    Mar 9, 2018 at 10:58
  • 2
    $\begingroup$ Use the option RegionFunction for Plot3D as shown in the documentation. $\endgroup$
    – gwr
    Mar 9, 2018 at 11:07
  • $\begingroup$ Even if a bit late: Welcome! I suggest that: 1) You take the introductory Tour 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – gwr
    Mar 9, 2018 at 14:46

1 Answer 1


Here is a simple example of how you might do it using RegionFunction. As proxy for a 3D-Plot I am using the binormal density from another post:

dist = BinormalDistribution[ {0, 0}, {1, 1}, 0.7 ] (* may sound familiar :) *)

  Plot3D[ PDF[dist, {x, y}], {x, -2, 2}, {y, -2, 2},
      RegionFunction -> Function[{x, y}, (x + y > 1) || (x + y < -1)],
      PlotRange -> All
  Plot3D[  PDF[dist, {x, y}], {x, -2, 2}, {y, -2, 2}, 
      RegionFunction -> Function[{x, y}, x + y <= 1 && x + y >=  -1],
      PlotStyle -> Red

enter image description here

  • $\begingroup$ Note that for a good result I negated the exlusions for the primary plot. $\endgroup$
    – gwr
    Mar 9, 2018 at 11:33
  • $\begingroup$ How can I bring a part of my calculations here? Sorry, I'm a beginner :/ $\endgroup$ Mar 9, 2018 at 14:20

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