# Smooth framerate in Mathematica animations?

I'm trying to figure out how to get animations to render smoother in Mathematica. I'm very new to this but I'd like to get a 30fps animation of something. Here's a simple example:

Animate[Plot[Sin[a*x],{x,-2Pi,2Pi}],{a,-1,1,.05},RefreshRate->40]

However, this is not a smooth animation at all. I tried manipulating both step size and refresh rate, but neither seem to work. Am I missing something? I tried this both in cloud and desktop.

Generate the slides outside of the Animate, i.e.

slides = Table[Plot[Sin[a*x], {x, -2 Pi, 2 Pi}, PlotRange -> {{-2 Pi, 2 Pi}, {-1, 1}}],
{a, -1, 1, .01}];
Animate[slides[[i]], {i, 1, 201, 1}, RefreshRate -> 40]


Otherwise, Animate will try to generate them on the fly, which can slow things down.

Hopefully this helps achieve what you're after.

• Thanks for the response! This still seems to be giving me very slow framerates. Commented Sep 20, 2017 at 4:52
• Maybe my computer is faster so I didn’t notice that. Perhaps export the slides as a GIF, at which point they’d be at a standard speed?
– ktm
Commented Sep 20, 2017 at 4:53
• This works! Thanks! Why does the methods I presented in my question not work? Commented Sep 20, 2017 at 5:15
• @rb612 "Otherwise Animate will try to generate them on the fly, which can slow things down."
– ktm
Commented Sep 20, 2017 at 13:33

ListAnimate is probably what you're looking for. Set up your slides:

slides = Table[
Plot[Sin[a*x], {x, -2 Pi, 2 Pi},
PlotRange -> {{-2 Pi, 2 Pi}, {-1, 1}}], {a, -1, 1, 0.05}];


Then ListAnimate allows you to specify the frames per second directly in the second argument:

ListAnimate[slides, 40]


Obviously, you can mess with the stepsize in your Table to get the length of the animation right.

• Thank you for the answer! This looks like it should work, but the animation is being generated when I call it, so it's still running at a few fps. It won't even run when I'm at 40fps Commented Sep 20, 2017 at 4:51
• @rb612 It won't be re-generating the plots when you call ListAnimate. ListAnimate just runs through whatever list you give it. All I can think is that there's something else sucking up your resources (unless you're using SetDelayed, :=, or something). Commented Sep 20, 2017 at 8:00

I was close to giving up on Mathematica, which I'd bought for visualisation as much as for its symbolic abilities, but recently I found that using Dynamic[] gives much smoother animations than Animate or Manipulate

Execute this in one cell

Dynamic[Plot[Sin[a*x], {x, -2 Pi, 2 Pi}]]


And this in another

For[a = -1, a < 1, a = a + .05, Pause[0.1]]


You may need to adjust the step size and the pause duration.