I am trying to extract the points from the mesh lines of a 3D plot. (Not my actual function.)
p = Plot3D[Sin[x]^2*Cos[y], {x, -1, 1}, {y, -1, 1}, MeshFunctions -> {#1^2+#2^2 &}]
![enter image description here][1]
I found a similar question here. So I used the code suggested.:
p2 = p // Cases[#, GraphicsComplex[Line_, ___] :> Line] &;
p3 = Flatten[p2, 1];
ListPlot[p3[[All, 1 ;; 2]]]
![enter image description here][2]
[1]: https://i.sstatic.net/HH4pD.jpg
[2]: https://i.sstatic.net/iHVYu.jpg
As you can see, I am getting a bunch of points that are not on the mesh lines. When I increase the PlotPointsPlotPoints
, it gets even worse.
How can I extract only the points on the mesh lines?