3
$\begingroup$

I would like to know if there is a way to extract $x$, $y$, $z$ points from ParametricPlot3D.

ParametricPlot3D[{a1, b1, c1, d1, f1, g1, h1, i1, j1}, {t, 3, 4}, {w, 
0, 2 \[Pi]},
  Axes -> True, AxesStyle -> {Red, Green, Blue},
  AxesStyle -> {Red, Green, Blue}, PlotStyle -> {Red, LightPink},
  Mesh -> None]

ParametricPlot3D[{a1, b1, c1, d1, f1, g1, h1, i1, j1}, {t, 3, 4}, {w, 
0, 2 \[Pi]},
  Axes -> False, Boxed -> False,
  PlotStyle -> {Red, LightPink}, Mesh -> None]

a

$\endgroup$
3
  • $\begingroup$ Welcome to Mathematica.SE, NurFadhilah! I 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 and check the faqs! 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! $\endgroup$
    – Chris K
    Commented Apr 23, 2019 at 9:30
  • $\begingroup$ I'm not sure why don't you just change ParametricPlot3D to Table (without any options)? This will output the points basically… $\endgroup$
    – SHuisman
    Commented Oct 6, 2023 at 14:21
  • $\begingroup$ There is an example in the ParametricPlot3D documentation under Options->EvaluationMonitor: $$ $$ pts = Reap[ParametricPlot3D[{Cos[ϕ] Sin[θ], Sin[θ] Sin[ϕ], Cos[θ]}, {ϕ, -π, π}, {θ, 0, π}, EvaluationMonitor :> Sow[{Cos[ϕ] Sin[θ], Sin[θ] Sin[ϕ], Cos[θ]}]]][[-1, 1]]; $$ $$ (modified from documentation slightly to just grab points) $\endgroup$
    – ydd
    Commented Oct 6, 2023 at 14:35

1 Answer 1

5
$\begingroup$

We have, for example:

plot1 = ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 2 \[Pi]}, {v, -\[Pi], \[Pi]}]

enter image description here

Then we can extract the points using the following:

pts=Flatten[Cases[plot1, _GraphicsComplex , Infinity][[;; , 1]], 1]

We can then superimpose them on an already existing plot:

Show[plot1, Graphics3D[Point[pts]]]

enter image description here

Or we can save them as a .txt document, in the form of a table:

Export["data.txt", pts, "Table"]

To access them in Mathematica, you can simply do, for instance:

pts[[1]]

{1., -1., -4.48799*10^-7}

I hope this helps.

$\endgroup$
2
  • 1
    $\begingroup$ More directly you can get the points with plot1[[1,1]] $\endgroup$ Commented Apr 23, 2019 at 10:33
  • $\begingroup$ This is outstanding helpful. It also works for FeatureSpacePlot3D and DimensionReduce. $\endgroup$ Commented Apr 19, 2021 at 2:14

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.