3
$\begingroup$

Suppose there is the function Exp[-(x^2+y^2)] which covers a certain volume under its surface. That can be easily illustrated by

Plot3D[Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}].

How can I split the volume under the surface into two pieces and color them differently?

I'm trying something like

Plot3D[Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x + y < 0]]

which leaves just one part of the split volume.

$\endgroup$
3
  • $\begingroup$ Are you looking to actually color the volume under the surface (e.g. between surface and the xy-plane), or are you simply trying to color the surface itself in two different colors (one for each region/piece)? $\endgroup$
    – Lukas Lang
    Jan 7, 2023 at 11:01
  • $\begingroup$ The first mentioned option: the volume under the surface and xy plane. $\endgroup$ Jan 7, 2023 at 11:15
  • 1
    $\begingroup$ mathematica.stackexchange.com/questions/262896/… $\endgroup$
    – cvgmt
    Jan 7, 2023 at 11:45

2 Answers 2

3
$\begingroup$
Show[MapThread[RegionPlot3D[Exp[-(x^2 + y^2)] - z > 0 && #1
    , {x, -2, 2}, {y, -2, 2}, {z, 0, 1.2}
    , PlotPoints -> 60
    , MaxRecursion -> 4
    , Mesh -> 3
    , MeshStyle -> #2
    , PlotStyle -> Directive[Opacity[0.5], Lighter@#2]
    ] &
  , {{x + y < 0, x + y >= 0}, {Red, Blue}
   }
  ]
 ]

enter image description here

$\endgroup$
3
$\begingroup$

Something like:

Plot3D[{Exp[-(x^2 + y^2)]}, {x, -2, 2}, {y, -2, 2}, 
 RegionFunction -> Function[{x, y, z}, x + y < 0], Filling -> Bottom, 
 FillingStyle -> Green]

enter image description here

$\endgroup$

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.