# Restrict 3D plot to region specified by an inequality

I would liked to plot a piece of the unit sphere surface within the region defined by

$$x \geq y \geq z \geq 0$$

Plotting the region (RegionPlot3D) and the sphere (Graphics3D) is no problem, but I would like to restrict the plot domain to the area specified by the inequality, i.e. I want the intersection between the volume and the sphere surface. Is that possible?

• RegionPlot3D[ 0 < z <= y <= x && x^2 + y^2 + z^2 <= 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, PlotPoints -> 100, Mesh -> None]?
– kglr
Jan 30 '18 at 19:09
• what have you tried? Jan 30 '18 at 19:19
• @kglr That'll do it for the moment, thanks. Any way to plot the surface only? Jan 30 '18 at 19:43
• @José Antonio Díaz Navas As I said, plotting the region and my sphere's surface independently is not the problem, I'm just looking for a built-in method to restrict any existing plot to any arbitrary region, when these two items can be plotted separately. There's not much I can try but to inquire about features unknown to me. Jan 30 '18 at 19:47

With region = 0 <= z <= y <= x you can use

RegionPlot3D[region && x^2 + y^2 + z^2 <= 1,
{x, 0, 1}, {y, 0, 1}, {z, 0, 1}, PlotPoints -> 100, Mesh -> None]


Any way to plot the surface only?

You can use ParametricPlot3D or ContourPlot3D to get the surface of a sphere:

ParametricPlot3D[{Cos[v] Sin[u], Sin[v] Sin[u], Cos[u]}, {u, 0, Pi}, {v, 0, 2 Pi},
Mesh -> None, BoundaryStyle -> None,      MaxRecursion -> 5, PlotPoints -> 100,
RegionFunction -> Function[{x, y, z, u, v}, region]]


ContourPlot3D[x^2 + y^2 + z^2 == 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
RegionFunction -> Function[{x, y, z, u, v}, region],
MaxRecursion -> 5, PlotPoints -> 100, Mesh -> None,
BoundaryStyle -> None]


Alternatively,

ParametricPlot3D[ConditionalExpression[{Cos[v] Sin[u], Sin[v] Sin[u], Cos[u]},
0 < Cos[u] <= Sin[v] Sin[u] <= Cos[v] Sin[u]],
{u, 0, Pi}, {v, 0, 2 Pi},
Mesh -> None, BoundaryStyle -> None,  MaxRecursion -> 5, PlotPoints -> 100]


• RegionFunction, that's it! Thank you. Jan 30 '18 at 20:10
• @kglr no need to use ParametricPlot3D to get the surface, just ContourPlot3D don't you? Jan 30 '18 at 20:13
• @JoséAntonioDíazNavas, you are right; just added that alternative.
– kglr
Jan 30 '18 at 20:14