6

While manipulating the slider in Manipulate[], I experience choppy curves. These do however render correctly after letting go of the slider. The same phenomenon occurs when pressing the + or - button or play-button.

An example of this is shown below.

The question is of course how to avoid this. Any suggestions?

Manipulate[
 Plot[Sin[x] + Sin[a x], {x, 0, 10}, 
  PlotStyle -> Thickness[0.002]], {{a, 10}, 1, 100, 1}]

Plot while holding the slider: enter image description here

After some seconds a smooth plot is presented: enter image description here

EDIT: Applying PerformanceGoal -> "Quality" suggested by kguler solves this problem, however some gaps appear at certain values, see below: enter image description here

MathLind
  • 1,697
  • 1
  • 13
  • 22
  • Closely related: 45858 and probably a duplicate – Kuba Sep 16 '14 at 19:25
  • @Kuba, yes you are correct. However in spite of searching a good while before posting, I didn't find them. How did you find them so fast? – MathLind Sep 16 '14 at 20:22
  • I knew what to look for so don't blame yourself :) – Kuba Sep 16 '14 at 20:46
  • 1
    Regarding the second problem you can use ControlActive to specify sufficiently high PlotPoints. Please see these for an understanding of the problem: (4572183), (29346) Also my own answer to: (8482) – Mr.Wizard Sep 17 '14 at 14:25
  • @Mr.Wizard, Thank you for the highly instructive links. Again, I'm amazed how you find these links. – MathLind Sep 17 '14 at 14:37
  • @MathLind I remembered (some of the content of) one of them, and from there I was able work my way to the other two. If I had remembered my own (simpler) answer first I would have found links to the first two but I did it backward. Get in the habit of looking at the "Linked" section of the sidebar to the right of a question; sometimes they are only tangentially related but fairly often there is good information, and one link often leads to another. – Mr.Wizard Sep 17 '14 at 14:40

2 Answers2

5

Use the option PerformanceGoal->"Quality":

Manipulate[
 Plot[Sin[x] + Sin[a x], {x, 0, 10}, PlotStyle -> Thickness[0.002], 
  PerformanceGoal -> "Quality"], {{a, 10}, 1, 100, 1}]

From the docs:

PerformanceGoal > Details

The typical default setting for PerformanceGoal is $PerformanceGoal.

\$PerformanceGoal > Details

The typical default value of $PerformanceGoal is ControlActive["Speed","Quality"].

kglr
  • 394,356
  • 18
  • 477
  • 896
  • This solves the issue. But if I set "a" to 89 in your example, I get a big gap around 1<x<1.25 at least on my screen. Do you experience this as well? – MathLind Sep 16 '14 at 19:28
  • 1
    @MathLind, yes i see the same gap (version 9.0.1.0 Windows 8 64bit). See also a=53. Setting PlotPoints and MaxRecursion very high (e.g., PlotPoints -> 200, MaxRecursion -> 15)seems to get rid of such gaps -- at the cost of speed, of course. – kglr Sep 16 '14 at 19:36
  • PlotPoints -> 200, MaxRecursion -> 5seems to suffice on my system. The lagging is bearable. – MathLind Sep 16 '14 at 19:58
3

You can use PlotPoints adaptively so to calculate one point per period (aprox)

Manipulate[
 Plot[Sin[x] + Sin[a x], {x, 0, 10}, PlotStyle -> Thickness[0.002], 
  PlotPoints -> IntegerPart[10  a/2 Pi] ], {{a, 10}, 1, 100, 1}]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453