I would like to generate a gif (or mkv) from a loop within which a figure is created at each iteration. Most Makie example I saw first create a figure, then modify it in an iteration. Could someone help me getting this Plots.jl MWE into a Makie one?
using Plots
let
anim = @animate for it=1:10
p = plot(title="Animation")
p = plot(1:10, (1:10).^2, label=:none)
p = scatter!([it], [it^2], label=:none)
end
gif(anim, "anim_MWE.gif", fps = 5)
end
using GLMakie
import Makie.SpecApi as S
let
fig, _, spec = plot(S.GridLayout()) # create empty spec plot
record(fig, "anim_MWE.gif", 1:10) do it
# update the spec
spec[1] = S.GridLayout(S.Axis(title="Animation", plots=[
S.Lines(1:10, (1:10).^2),
S.Scatter([it], [it^2], )
]))
end
end
It’s still a bit cumbersome in comparison, but could be made nicer for such animations.
Otherwise, for the old fashioned approach, I’d have a look at the docs: https://docs.makie.org/stable/explanations/animation/