7
$\begingroup$

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]

enter image description here

setting InterpolationOrder->2 gives a smoother plot, enter image description here

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ May 29, 2013 at 5:05
  • $\begingroup$ 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. $\endgroup$
    – Mr.Wizard
    May 29, 2013 at 5:09
  • $\begingroup$ @Mr.Wizard I think both. On my computer I can't get the plot start rotating. Also the entire frontend seems lagging. $\endgroup$ May 29, 2013 at 15:36

2 Answers 2

5
$\begingroup$

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:

enter image description here

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]]
     }]
   ]
  ]
 ]
$\endgroup$
4
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Try to replace "MouseDown" with "MouseMoved". I wonder why this works instantly while the button event needs time until it gets recognized. $\endgroup$
    – halirutan
    Jun 2, 2013 at 2:05

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.