# Getting a 2D slice out of a 3D ParametricPlot [closed]

I have generated a 3D plot of a surface using the ParametricPlot3D command.

Considering the three axes of the 3D plot to be x, y and z I would like to obtain a 2D plot showing surface boundaries for a specific z value.

Is there any relatively straightforward way to do that?

• Why not use ParametricPlot with fixed z instead of ParametricPlot3D? If it's a problem of coordinate transformations, it would be good to see an actual example with code you have already tried.
– Jens
Commented Mar 8, 2015 at 3:36
• Are you trying to impose the 2D plot on top of the 3D plot? Commented Mar 8, 2015 at 4:06
• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 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. Commented Mar 8, 2015 at 4:16
• Why is this getting flagged for being reopened? The issues haven't been addressed, and it's over a year and a half old. Commented Nov 15, 2016 at 13:19

Here's a way to get the 2D graphics from an already-generated plot.

tori = ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u],
4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]}, {8 + (3 + Cos[v]) Cos[u],
3 + Sin[v], 4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0,
2 Pi}, PlotStyle -> {Red, Green}, Mesh -> None,
PlotStyle -> Thickness[0.1]];

With[{z0 = 4},
RegionPlot3D[DiscretizeGraphics[tori], MeshFunctions -> {#3 &},
Mesh -> {{z0}},
MeshStyle -> {Directive[Thick, Blue]},
PlotStyle -> None] /.
Graphics3D[g_, opts___] :>
Graphics[g /. {x_Real, y_Real, z_Real} :> {x, y},
FilterRules[{opts}, Graphics], Frame -> True]
]


Animation from Table[<plot code>, {z0, 0, 8, 0.2}]:

• Pretty neat this. Bit more on z range would make first torus vanish altogether... Can we also get a table of x-,y- values for some z = constant section? Which independent variable is uniformly incremented in the section? Commented Mar 8, 2015 at 18:50
• @Narasimham The z coordinate is increased (see Table code above animation). The x, y values can be obtained with Cases[regionplot, GraphicsComplex[pts_, __] :> pts, Infinity]. Commented Mar 8, 2015 at 19:13

You can use ClipPlanes.

Using the same example from the docs as Zviovich:

tori = ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u],
4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]}, {8 + (3 + Cos[v]) Cos[u],
3 + Sin[v], 4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0,
2 Pi}, PlotStyle -> {Red, Green}];

Show[tori, ClipPlanes -> {{0, 0, -1, 4}}]


This seems a reasonable approach when computing the initial plot (tori) is expensive.

Show[{ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u],
4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]}, {8 + (3 + Cos[v]) Cos[u],
3 + Sin[v], 4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0,
2 Pi}, PlotStyle -> {Red, Green},
RegionFunction -> Function[{x, y, z}, z < 4]],
ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u], 4 + (3 + Cos[v]) Cos[u],
4}, {8 + (3 + Cos[v]) Cos[u], 3 + Sin[v], 4}}, {u, 0, 2 Pi}, {v,
0, 2 Pi}, PlotStyle -> {Red, Green}]}]


Update: Using a combination of MeshFunctions, ViewPoint and PlotStyle:

ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u], 4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]},
{8 + (3 + Cos[v]) Cos[u], 3 + Sin[v], 4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
ViewPoint -> {0, 0, Infinity}, MeshFunctions -> {Function[{x, y, z, u, v}, z]},
Mesh -> {{{3.5, Directive[Thick, Red]}}}, Boxed -> False, Axes -> False, PlotStyle -> None]


Animate[ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u],  4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]},
{8 + (3 + Cos[v]) Cos[u], 3 + Sin[v], 4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
ViewPoint -> {0, 0, Infinity},  MeshFunctions -> {Function[{x, y, z, u, v}, z]},
Mesh -> {{{t, Directive[Thick, Red]}}}, Boxed -> False,
Axes -> False, PlotStyle -> None, PerformanceGoal -> "Quality"],
{t, 0., 8., .005},
AnimationRate -> 2, AnimationRunning -> False,  AnimationDirection -> ForwardBackward]


Original post:

Also using Zviovich's example:

ParametricPlot3D[{ConditionalExpression[{4 + (3 + Cos[v]) Sin[u],
4 + (3 + Cos[v]) Cos[u], 4 + Sin[v]},  Sin[v] < 0],
ConditionalExpression[{8 + (3 + Cos[v]) Cos[u], 3 + Sin[v],
4 + (3 + Cos[v]) Sin[u]}, (3 + Cos[v]) Sin[u] < 0]},
{u, 0, 2 Pi}, {v, 0, 2 Pi}, PlotStyle -> {Red, Green},
PlotRange -> {Automatic, Automatic, {0, 8}}, MaxRecursion -> 6]


• @ Michael E2 possible to get x-, y- on Ver 8.0? Commented Mar 10, 2015 at 19:52

I borrowed Zviovich's doughnuts to manipulate at variable $x$ Box limited Toric sections.

Manipulate[ParametricPlot3D[{{4+(3+Cos[v]) Sin[u],4+(3+Cos[v]) Cos[u],4+Sin[v]},{8+(3+Cos[v]) Cos[u],3+Sin[v],4+(3+Cos[v]) Sin[u]}},{u,0,2 Pi},{v,0,2 Pi},PlotStyle->{Yellow},Axes-> None, Boxed-> False,Mesh->{40,12},PlotRange-> {{0,xm},{0,8},{0,8}}], {xm,1,12,0.5}]


This may help to visualize 2D "Almost"

ParametricPlot3D[{{4 + (3 + Cos[v]) Sin[u], 4 + (3 + Cos[v]) Cos[u],
4 + Sin[v]}, {8 + (3 + Cos[v]) Cos[u], 3 + Sin[v],
4 + (3 + Cos[v]) Sin[u]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
PlotStyle -> {Yellow}, Axes -> None, Boxed -> False,
PlotRange -> {{xm - .1, xm}, {0, 8}, {0, 8}},
PlotLabel -> "ALMOST_2D"]