Currently, I have a matrix containing a list of spherical coordinates. Column 1 is r; r=1 for all points. Column 2 is theta and column 3 is phi. Each row is an ordered triple (r,theta,phi). Is there a function that I can get to operate on this matrix and plot these points on a sphere of radius 1? Thank you!


  • 1
    $\begingroup$ Transform the coordinates to Cartesian form, then use ListPointPlot3D. $\endgroup$
    – Szabolcs
    Commented Jul 17, 2014 at 15:13
  • $\begingroup$ Could you share your points? $\endgroup$ Commented Jul 17, 2014 at 15:13
  • $\begingroup$ @MarkMcClure My points are constantly changing as they're based upon roots of different polynomials. One example would be (1, pi/2, pi/4). $\endgroup$ Commented Jul 17, 2014 at 15:21
  • $\begingroup$ @Szabolcs I think I'll combine your command with George's command. Will ListPointPlot3D apply to a matrix of triples? $\endgroup$ Commented Jul 17, 2014 at 15:23
  • $\begingroup$ @ChaseYetter ListPointPlot3D can accept a matrix but that is probably not what you want: it will interpret each row as a separate sequence of points, and give them a different color. You can use Flatten[matrix, 1] to turn it into a list of points. $\endgroup$
    – mfvonh
    Commented Jul 17, 2014 at 15:42

2 Answers 2

 CoordinateTransformData[ "Spherical" -> "Cartesian", "Mapping", #]&/@ datalist


 Graphics3D@{Sphere[{0, 0, 0}, .95], 
    Point[CoordinateTransformData["Spherical" -> "Cartesian", 
           "Mapping", #] & /@ 
          Table[ { 1, RandomReal[{0, Pi}], RandomReal[{-Pi, Pi}]}, {2000}]]}

enter image description here

It may also be useful to see how you can roll your own:

 sp[{r_, theta_, phi_}] := 
      r {Cos[phi] Cos[theta], Cos[phi] Sin[theta], Sin[phi]};
 Graphics3D@{Sphere[{0, 0, 0}, .95],
 Point[ sp /@ Table[ { 1, RandomReal[{0, 2 Pi}], RandomReal[{-Pi/2, Pi/2}]}, {2000}]]}

(same graphic)

note here I use a different convention on the ordering of the spherical coordinates and and the range of theta.


You can transform all your data points to xyz and plot them.

data = Flatten[Table[{1, theta, phi}, {phi, 0, 2 Pi, Pi/10.}, {theta, 0, Pi, 
 Pi/10.}], 1]; (*your set of data*)

rtox[sphdata_] := sphdata /. {r_, theta_, phi_} -> CoordinateTransform["Spherical" -> "Cartesian", {r, theta, phi}]
(*to change your table to cartesian from spherical*)

ListPointPlot3D[rtox[data], BoxRatios -> 1]

And your are done.


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.