Adding a curve to a 3D region plot

I am trying to find out how to plot a curve (or a more general area) on the surface of an object illustrated by RegionPlot3D.

Assume for example I plot a sphere

RegionPlot3D[x^2+y^2+z^2<1,{x,-1,1},{y,-1,1},{z,-1,1}]


and I now want to add an illustration of all points that are on the sphere plus satisfy a further condition (such as y = 0 or even y>0). Does somebody know a way to do this?

I want to apply this to a slighty more complicated situation, so a general answer that doesn't depend on the exact type of geometry would be best!

• Dec 18, 2017 at 10:26
• Banana, welcome to mathemica.se! We suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour 3) 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.
– kglr
Dec 19, 2017 at 3:01

One way is to use Mesh options as follows:

legends = {{SwatchLegend[{Green}, {Style["  y  >  0 ", 16]}],
Right}, {LineLegend[{Red}, {Style["y == 0", 16]}], Right}};

Legended[RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
MeshFunctions -> {#2 &}, Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick],
MeshShading -> {Automatic, Green}, PlotStyle -> Opacity[.5]], legends]


Another example:

meshf = 3 Sin[# #2 #3] + Cos[#2 #3] - 1 &;
mesh = {-.1};
RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
MeshFunctions -> {meshf }, Mesh -> {mesh},
MeshStyle -> Directive[Red, Thick],
MeshShading -> {Automatic, Opacity[.7, Green]}, PlotPoints -> 100,
PlotStyle -> Opacity[.5]]


And with

meshf = Evaluate[Sum[Sin[RandomReal[5, 3].{#, #2, #3}], {7}]] &;
mesh = {-1, 0, 1};;


• This looks like a very nice idea! I will try this. However the reason I was saying "more general area" is because I tend to believe that my extra condition, stated as F(x,y,z)=c, does not describe a curve, but rather a mixture between curves, surface areas and points. This is only applicable for conditions that describe a curve on my object, do I understand that correctly? Dec 18, 2017 at 7:35
• @LiftingBanana, it would be helpful if you post and example of F(x,y,z) = c describing something other than a curve.
– kglr
Dec 18, 2017 at 7:47
• @klgr Unfortunately I can't think of any, at the moment, as I don't know the geometry of my problem (which is why I was looking for the plotting methods). I can imagine such situations geometrically though. I will try what you added as it seems very promising and tune back in if it shouldn't work. Thank you very much for the detailed mesh examples! Dec 18, 2017 at 8:55
• @LiftingBanana, my pleasure. Welcome to mma.se.
– kglr
Dec 18, 2017 at 8:57