# Efficient ways to rotate a ListPlot?

I have a numerical solution from a differential equation that is in the form of a list, in $(x,z)$-plane. I would like to rotate the 2D ListPlot around the $z$-axis to generate a 3D plot. The length of the list is $25\,000$; the step size between each point is $0.0003$.

I have tried rotate each point $36$ degrees for $9$ times to obtain a list of triples and then use ListPlot3D. This method, however, takes about $5$ minutes to generate a plot. Is there a more efficient way of rotating a 2D ListPlot?

I was thinking about cutting off the number of points being rotated. How many points can I omit to retain most of the features of the original plot?

• You could use Interpolation to create an interpolating function and plot it using RevolutionPlot3D. Is this what you're looking for? – Szabolcs Dec 8 '13 at 2:13
• If you take a list of 3D points and take the dot product with a rotation matrix, it should be fast, even for 25000 points, provided that the points are all machine precision numbers (apply N to the list to make them machine precision). – Szabolcs Dec 8 '13 at 2:16
• 25000 is overkill: it is ~20 times more then pixels in your screen. Often ~1000 points is enough. – ybeltukov Dec 8 '13 at 2:18
• Thanks a lot! I will try both methods. – SlipStream Dec 8 '13 at 2:21

You can use Interpolation to interpolate the data, then plot it using RevolutionPlot3D. The plotting command won't actually sample the interpolation function at 25000 different points (which as @ybeltukov said, is overkill), so plotting will be much faster.

### Example:

Make sample data:

data = Table[{x, Sin[x]}, {x, 0., 2 Pi, 2 Pi/25000.}];


Interpolate:

if = Interpolation[data]


Plot:

RevolutionPlot3D[{if[x], x}, {x, 0, 2 Pi}]


Rotating the list of points by multiplying with a rotation matrix is not slow on my machine (it's much faster than plotting all $9\times 25000$ points):

rm = RotationMatrix[36. Degree, {1, 0, 0}]

ListPointPlot3D[Join @@ NestList[#.rm &, ArrayFlatten[{{data, 0}}], 9], BoxRatios -> Automatic]


When you do this, make sure that both the data and the rotation matrix are machine precision numbers (apply N to them to make sure this is the case).

• Thanks a lot! The interpolation method works great. – SlipStream Dec 8 '13 at 2:37
• @MichaelE2 I would definitely upvote this answer when I have enough reputation. – SlipStream Dec 8 '13 at 3:54
• @SlipStream Ah, I didn't know about the rep. restriction. Sorry to trouble you. – Michael E2 Dec 8 '13 at 3:59