I'm trying to create animation of some discrete process using Manipilate:

Manipulate[**Some graphics based on very slow computations, each step is calculated slowly then the previous**], {Step, 1, 1000, 1}]

It works fine if I move Step slider with the mouse.

But if I click the 'Play' button, animation starts but a lot of steps are missing. For example, I see the picture corresponding the 1st step, then the 13th, then 51st... And sometimes I even get '$Aborted'.

Manipulate options like ContinuousAction -> False don't make any change.

How can I make Manupulate display all the steps, one by one, with "Play' button?

  • $\begingroup$ Short way should be to adjust AnimationRate: {step, 1, 1000, 1, AnimationRate -> 1, Appearance -> "Open"}] $\endgroup$ – Kuba Jan 15 '14 at 9:53
  • $\begingroup$ But as I said computation time is different for each step, so it's impossible to find proper constant AnimationRate. $\endgroup$ – Epik17 Jan 15 '14 at 10:02
  • $\begingroup$ Better use Animate here and let it calculate all steps in advance $\endgroup$ – Sjoerd C. de Vries Jan 15 '14 at 10:44
  • $\begingroup$ @SjoerdC.deVries Thanks, it will work for sure, but in this case we need a lot of memory to store each step data :( $\endgroup$ – Epik17 Jan 15 '14 at 11:40
  • 2
    $\begingroup$ Converting the graphics to a bitmap may help if the number of graphical objects is high. $\endgroup$ – Sjoerd C. de Vries Jan 15 '14 at 11:47

You are looking for the option DisplayAllSteps -> True in Animate:

(* plot with a random lag *)
plot[r_] := (Pause[RandomReal[]]; Plot[Sinc[r/10 x], {x, 0, 10}])

Animate[plot[z], {z, 1, 50, 1}, DisplayAllSteps -> True]

This code fails with an $Aborted if the rendering takes more than five seconds, because of the default Dynamic timeout. Michael explained how to use DynamicEvaluationTimeout to solve this as follows:

(* plot with a longer lag *)
plot[r_] := (Pause[6]; Plot[Sinc[r/10 x], {x, 0, 10}]);

  Animate[plot[z], {z, 1, 50, 1}, DisplayAllSteps -> True],
  DynamicEvaluationTimeout -> 100
  • $\begingroup$ In this case I get $Aborted when Step is rather big. The problem was discussed here groups.google.com/forum/#!topic/comp.soft-sys.math.mathematica/… $\endgroup$ – Epik17 Jan 15 '14 at 11:50
  • $\begingroup$ @Epik17 I believe that only happens when the rendering lag is quite high; if it is that high this won't really count as an "animation" at that point. Nevertheless there should be a work-around for that; let me see if I can find it. $\endgroup$ – Mr.Wizard Jan 15 '14 at 11:56
  • $\begingroup$ I will be grateful if you find it. $\endgroup$ – Epik17 Jan 15 '14 at 12:03
  • 1
    $\begingroup$ FYI: It's there in V7, perhaps: reference.wolfram.com/legacy/v7/note/… $\endgroup$ – Michael E2 Jan 15 '14 at 12:17
  • 1
    $\begingroup$ Feel free to incorporate it. DisplayAllSteps is your contribution. I've got to take my daughter to school now and start my day. I'll think about other ways. $\endgroup$ – Michael E2 Jan 15 '14 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.