# Why Interpolation makes ListPlot3D slow?

I'm trying to use ListPlot3D to plot some data, and I'm using the InterpolationOrder option to make the plot smoother. But the output plot is not very responsive when rotate or edit with the drawing tool. Here is an example:

ls = Table[Sinc[x*y], {x, -10, 10, 0.2}, {y, -10, 10, 0.2}];
ListPlot3D[ls, PlotRange -> All]


setting InterpolationOrder->2 gives a smoother plot,

The problem is the second plot response very slowing when rotate with the mouse. So is it possible to produce an interpolated smooth but very responsive plot?

Here is what I've tried so far

f = ListInterpolation[ls, {{-10, 10}, {-10, 10}}];
ListPlot3D[Table[f[x, y], {x, -10, 10, 0.1}, {y, -10, 10, 0.1}],
PlotRange -> All];


this gives nicer plot than the first one, but is still seems not as good as the second one. Adding more points seems makes the plot unresponsive.

-
I see that Manipulate sometimes produce a down sampling plot to make the slider very responsive, and produce a nicer one when the slider stops (for example Manipulate[Plot3D[Sin[n x y], {x, -2, 2}, {y, -2, 2}], {n, 1, 4}] ). Is it possible to create a 3d plot with similar feature, that is, when rotating the plot is responsive and only shows the down sampling (un-interpolated) one, when rotating stops it produces the nicer looking (interpolated) one? –  xslittlegrass May 29 '13 at 5:05
Is this question about a lag before rotation begins, about slow/choppy rotation once it has begun, or both? For antialiased graphics using ViewAngle as referenced here will improve performance during rotation, but not the lag before it. –  Mr.Wizard May 29 '13 at 5:09
@Mr.Wizard I think both. On my computer I can't get the plot start rotating. Also the entire frontend seems lagging. –  xslittlegrass May 29 '13 at 15:36

Let me give the idea for another approach which (at least on my machine) does not lag. The key problem seems to be when you try to rotate a complex graphic. Therefore, the basic idea behind the following is to use a simple graphic for the rotation and transfer the values to your complex graphic. The surprising thing is, that when you ControlActive inside this dynamic environment, the change to the simple form of your plot happens instantly.

In the following, please use the cuboid for rotation and see what happens:

With[{ls = Table[Sinc[x*y], {x, -10, 10, 0.2}, {y, -10, 10, 0.2}]},
With[{
speed = ListPlot3D[ls, PlotRange -> All, PlotStyle -> None],
quality =
ListPlot3D[ls, PlotRange -> All, InterpolationOrder -> 2]
},
DynamicModule[{vp = {1.3, -2.4, 2}, vc = {0.5, 0.5, 0.5},
vv = {0, 0, 1}},
Column[
{
Graphics3D[Cuboid[{0, 0, 0}], Boxed -> False,
SphericalRegion -> True,
Epilog -> Circle[Scaled[{0.5, 0.5}], 0.5],
ViewPoint -> Dynamic[vp], ViewCenter -> Dynamic[vc],
ViewVertical -> Dynamic[vv]],
Dynamic[
Deploy@Show[ControlActive[speed, quality], ViewPoint -> vp,
ViewCenter -> vc, ViewVertical -> vv, SphericalRegion -> True]]
}]
]
]
]

-

You could switch to a faster version of the plot when rotating with something like this:

qualityplot = ListPlot3D[ls, PlotRange -> All, InterpolationOrder -> 2];
speedplot = ListPlot3D[ls, PlotRange -> All];

DynamicModule[{displayed = qualityplot},
EventHandler[Dynamic[displayed], {
"MouseDown" :> (displayed = speedplot),
"MouseUp" :> (displayed = qualityplot)},
PassEventsDown -> True]]


It's very laggy switching from one state to the other though, so you might find it just as annoying as before.

-
Try to replace "MouseDown" with "MouseMoved". I wonder why this works instantly while the button event needs time until it gets recognized. –  halirutan Jun 2 '13 at 2:05