# Plotting spherical surfaces

I am trying to make surface plots of squashed spheres. The spheres are defined by a list of points. For simplicity, consider the round sphere:

pts = Flatten[
Table[{Sin[θ] Cos[ϕ], Sin[θ] Sin[ϕ],
Cos[θ]}, {θ, 0, π, π/14}, {ϕ, 0,
2 π, 2 π/14}], 1];


One way to plot this is:

ListPlot3D[{pts,
-pts,}
BoundaryStyle -> None,
ColorFunction -> "Rainbow",
InterpolationOrder -> 2,
BoxRatios -> {1, 1, 1}]


ListPlot3D has the nice feature that it interpolates the data to make a smooth surface. However, the northern and southern hemispheres are shaded differently, so there is a clear break at the equator: An alternative is to do

ListSurfacePlot3D[pts]


Now the shading is uniform (there is no break at the equator). However, the data is no longer interpolated (and interpolation is not an option for ListSurfacePlot3D), so the surface looks rough and lumpy: I am trying to find a solution that combines the best of both world: the smooth surface of ListPlot3D with the uniform shading of ListSurfacePlot3D.

• Are you asking how to fit an ellipsoid to a set of data points? Have you tried Sphere[]? How are the data points really generated? – Jens Aug 30 '14 at 19:13
• The actual data points I am interested in are not a sphere or an ellipsoid. The true surface has spherical topology (and a z -> -z symmetry), but can be an otherwise arbitrary shape. The data points are generated by a different program and then fed into mathematica. I just generated this simple sphere for illustrative purposes. – idj Aug 30 '14 at 19:58
• The InterpolationOrder in ListPlot3D is a red herring; the appearance of the plot does not change if you change the order to $1$. Mathematica does not support higher-order interpolation on unstructured data yet. The reason it still looks like a smooth surface is because the shading is being interpolated when the surface is rendered. – user484 Aug 30 '14 at 20:56

From the example using ListPlot3D, I assume that your data points can be described by a height function above the plane. In other words, they describe a convex shape with reflection symmetry at the z=0 plane.

Then the only thing you may have to modify is the lighting and the ratio of the axes for your 3D plot, to get a smoother appearance with uniform color as is stated in the question:

pts = Flatten[
Table[{Sin[θ] Cos[ϕ], Sin[θ] Sin[ϕ],
Cos[θ]}, {θ, 0, Pi, Pi/14}, {ϕ, 0,
2 Pi, 2 Pi/14}], 1];

ListPlot3D[{pts, -pts}, BoundaryStyle -> None,
ColorFunction -> (Orange &), InterpolationOrder -> 2,
BoxRatios -> Automatic,
Lighting -> {{"Directional", White, {3, 0, 0}}, {"Ambient",
LightGray}}] I put the directional light source in a position that illuminates both halves of the sphere equally, so that the equatorial "crease" doesn't show up (no matter how you rotate the output).

• Perfect, thanks so much! (I also appreciate belisarius's suggestion but at least for my data sets it introduced artifacts at the poles, whereas this solution gives a perfectly smooth result.) – idj Aug 31 '14 at 7:37

Just format your list such that SphericalPlot3D[] can handle it:

pts = Flatten[Table[{Theta, Phi, Cos[Theta]}, {Theta, 0, Pi, Pi/14}, {Phi, 0, 2 Pi, 2 Pi/14}], 1];
f = Interpolation[pts];
SphericalPlot3D[f[Theta, Phi], {Theta, 0, Pi}, {Phi, 0, 2 Pi}, ColorFunction -> "Rainbow",
Mesh -> None] 