Animate Plot with Many Frames Quickly with Makie

I have a data set where thousands of points are moving around over time with thousands of time steps. The problem I am having is that it is taking a very long time to generate the movie.

I’ve been making the movies with Makie. It seems that there is a pause on the order of a second or two between the generation of each frame. Here is an example piece of code that can reproduce the problem I am having.

using Makie

N = 1000
r = [(rand(5000, 2) .- 0.5) .* 25 for i = 1:N]
scene = scatter(r[1][:, 1], r[1][:, 2], markersize = 1, limits = FRect(-25/2, -25/2, 25, 25))
s = scene[end] # last plot in scene
record(scene, "output.mp4", r) do m
    s[1] = m[:, 1]
    s[2] = m[:, 2]
end
1 Like

With Plots you can use ENV["GKSwstype"]="nul" to deactivate the display. It does appear that toggling the display off significantly reduces the time to generate the animation. Is there a similar option to turn the display off with Makie?

Oh, this seems to be a pretty big regression…
Try:


N = 1000
r = [(rand(5000, 2) .- 0.5) .* 25 for i = 1:N]
scene = scatter(r[1][:, 1], r[1][:, 2], markersize = 1, limits = FRect(-25/2, -25/2, 25, 25))
s = scene[end] # last plot in scene
GLMakie.WINDOW_CONFIG.vsync[] = false
record(scene, "test.gif", r) do m
    s[1] = m[:, 1]
    s[2] = m[:, 2]
end

Is there a similar option to turn the display off with Makie ?

That wouldn’t make a difference with GLMakie.

Btw, you should best use an array of points!

N = 1000
r = [(rand(Point2f0, 5000) .- 0.5) .* 25 for i = 1:N]
scene = scatter(r[1], markersize = 1, limits = FRect(-25/2, -25/2, 25, 25))
s = scene[end] # last plot in scene
record(scene, "output.mp4", r) do m
    s[1] = m
end

Thanks, that solved the main issue I was having.

I can generate plots a whole lot faster now. I was wondering though, is there a way to stop the plot window from popping up every time I run this script?

AbstractPlotting.inline!(true) should do the trick

1 Like