I've got a function that maps a 2D plane onto a sphere (I'm trying to learn about Geodesics).


I want to plot this, but the Plot3D gives me only a single value for any given [X,Y] set of coordinates. At the least, I'd like something like a scatter chart (that is, just give it 3 coordinates and have it plot a point), but it would be nice to be able to generate a wire-frame so I could draw my solutions.


2 Answers 2


f[u_, v_] := {X[u, v], Y[u, v], Z[u, v]};
X[u_, v_] := Cos[v] Sin[u];
Y[u_, v_] := Sin[v] Sin[u];
Z[u_, v_] := Cos[u];


data = f @@@ RandomReal[{0, 2 Pi}, {5000, 2}];


enter image description here

However, you can get a smoother distribution with RandomPoint on a Sphere


data2 = RandomPoint[Sphere[{0, 0, 0}], 5000];


enter image description here

EDIT: Converting the points into a 3-D surface

ListSurfacePlot3D[data2, Axes -> False]

enter image description here

  • $\begingroup$ Your first approach is not correct. Pay your attention that the points flock near the poles. $\endgroup$
    – user64494
    Dec 17, 2019 at 8:01
  • 2
    $\begingroup$ @user64494 it's not incorrect — it's just a different distribution. $\endgroup$
    – Ruslan
    Dec 17, 2019 at 10:39
  • $\begingroup$ Great answer. Thank you. For extra points, can you make that into a wire-frame? $\endgroup$
    – Quark Soup
    Dec 17, 2019 at 15:22
  • 1
    $\begingroup$ @user64494 random doesn't imply uniform. $\endgroup$
    – Ruslan
    Dec 18, 2019 at 8:16
  • 1
    $\begingroup$ @user64494 - The OP did not specify that the points in the "scatter chart" should be uniformly distributed on the sphere. The first approach demonstrates that if you start with a uniform distribution in 2-D, the transformation does not produce a uniform distribution in 3-D. While RandomPoint[reg, n] gives a list of n pseudorandom points uniformly distributed in the region reg; if you were to transform these 3-D points on a sphere to 2-D, they would not be uniform in 2-D. $\endgroup$
    – Bob Hanlon
    Dec 18, 2019 at 14:09

Thanks to Bob Hanlon for his answer. Using that as a starting point, I was able to work out this, which is what I was really after:

ParametricPlot3D[{R[u, v]}, {u, 0, Pi}, {v, 0, 2*Pi}]

enter image description here


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.