# How do you plot random points in three dimensions?

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

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];


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.

Clear["Global*"]

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];

SeedRandom[1234]

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

Graphics3D[Point[data]]


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

SeedRandom[1234]

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

Graphics3D[Point[data2]]


EDIT: Converting the points into a 3-D surface

ListSurfacePlot3D[data2, Axes -> False]


• Your first approach is not correct. Pay your attention that the points flock near the poles. – user64494 Dec 17 '19 at 8:01
• @user64494 it's not incorrect — it's just a different distribution. – Ruslan Dec 17 '19 at 10:39
• Great answer. Thank you. For extra points, can you make that into a wire-frame? – Quarkly Dec 17 '19 at 15:22
• @user64494 random doesn't imply uniform. – Ruslan Dec 18 '19 at 8:16
• @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. – Bob Hanlon Dec 18 '19 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}]
`