Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

could you give me some input on how to create a list version of


When r[] is an explicit analytical function it's not an issue, but what if one numerically generates a list {{r1,theta1,phi1},...,{rn,thetan,phin}} and wants to visualize it in a similar manner? Any ideas?

share|improve this question
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 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! – chris Apr 1 '13 at 7:02
Thanks, Jensen. Worked for me. – user6677 Apr 1 '13 at 14:53

A quick way of doing this would be to take the data and apply an Interpolation to create a function that can be plotted with SphericalPlot3D. Here is an example:

data = Flatten[
   Table[{{theta, phi}, 
     N@Re@SphericalHarmonicY[2, 1, theta, phi]}, {theta, Pi/10, Pi, 
     Pi/10}, {phi, Pi/10, 2 Pi, Pi/10}], 1];

f = Interpolation[data];

SphericalPlot3D[f[theta, phi], {theta, 0, Pi}, {phi, 0, 2 Pi}]


Here you get a warning because extrapolation was used since the data range is smaller than the angle range I'm plotting. But that's normal.

Note that the data has to be arranged differently from the structure you gave in the question: It's of the form {{{theta1, phi1}, f1}, {{{theta2, phi2}, f2}, ...}

share|improve this answer

I was considering to advise the use of ListSurfacePlot3D to do this, but after tinkering with it for some while, I found it is awful for reconstruction of spherical plots.

Let's take an example from the documentation:

SphericalPlot3D[1 + 2 Cos[2 θ], {θ , 0, Pi}, {ϕ, 0, 2 Pi}]

Mathematica graphics

The surface could be sampled like this:

data = Flatten[Table[{1 + 2 Cos[2 θ], θ, ϕ}, {θ, 0, Pi, Pi/30}, {ϕ, 0, 2 Pi, 2 Pi/30}], 1];

In v9 we have got an easy way to transform coordinates form spherical to Cartesian:

mapping =  CoordinateTransformData["Spherical" -> "Cartesian", "Mapping"]

{Cos[#1[[3]]] Sin[#1[[2]]] #1[[1]], Sin[#1[[2]]] Sin[#1[[3]]] #1[[1]], Cos[#1[[2]]] #1[[1]]} &

Those without v9 can use the pure function in the output above.

This works fine withListPointPlot3D:

ListPointPlot3D[mapping /@ data, BoxRatios -> Automatic]

Mathematica graphics

However, it gets absolutely horrible results with ListSurfacePlot3D

ListSurfacePlot3D[mapping /@ data, BoxRatios -> Automatic]

Mathematica graphics

Increasing sampling density doesn't help at all. Neither does the application of the MaxPlotPoints->Infinity option. So, it looks like that Jens' answer is the best solution in this case.

share|improve this answer
This is quite odd. With /90 in both Table iterators and MaxPlotPoints -> 125 I get this: Fairly different, wouldn't you say? :^) – Mr.Wizard Apr 1 '13 at 11:04
@Mr.Wizard Are you sure you havent used ListPlot3D instead of ListSurfacePlot3D? – Sjoerd C. de Vries Apr 1 '13 at 15:57
@mr.wizard Back at the keyboard and can confirm what you got there. I tried increasing MaxPlotPoints to 500, but it brings my PC to its knees. – Sjoerd C. de Vries Apr 1 '13 at 19:44
I think this is worthy of its own question. I'd like to know why that happens and if there are Method options etc., that better handle this case. Will you ask? – Mr.Wizard Apr 1 '13 at 22:31
@Mr.Wizard It doesn't look answerable to me. Perhaps more an issue for WRI support. – Sjoerd C. de Vries Apr 2 '13 at 5:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.