# Animate Plot with Many Frames Quickly with Makie

**URL:** <https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [August 1, 2020, 4:56pm UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094 "2020-08-01T16:56:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tross](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tross](https://discourse.julialang.org/u/tross)\
**Post date:** [August 1, 2020, 4:56pm UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094/1 "2020-08-01T16:56:55Z")

</div>

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.

```julia
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

```

---

<div class="post-metadata">

**Author:** ![tross](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tross](https://discourse.julialang.org/u/tross)\
**Post date:** [August 2, 2020, 10:16pm UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094/2 "2020-08-02T22:16:21Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [August 3, 2020, 9:17am UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094/3 "2020-08-03T09:17:27Z")

</div>

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

```julia

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!

```julia
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

```

---

<div class="post-metadata">

**Author:** ![tross](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tross](https://discourse.julialang.org/u/tross)\
**Post date:** [August 3, 2020, 10:33pm UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094/4 "2020-08-03T22:33:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [August 3, 2020, 10:35pm UTC](https://discourse.julialang.org/t/animate-plot-with-many-frames-quickly-with-makie/44094/5 "2020-08-03T22:35:51Z")

</div>

AbstractPlotting.inline!(true) should do the trick
