@gif without saving all images

Is it possible to generate an animation with @gif without saving all images to disk?

Yes it is possible, what package that you use to generate the gif?

1 Like

Plots, with GR()

I use an example of animation from this website:

I just add gr() at the second line

using Plots

@userplot CirclePlot
@recipe function f(cp::CirclePlot)
    x, y, i = cp.args
    n = length(x)
    inds = circshift(1:n, 1 - i)
    linewidth --> range(0, 10, length = n)
    seriesalpha --> range(0, 1, length = n)
    aspect_ratio --> 1
    label --> false
    x[inds], y[inds]

n = 150
t = range(0, 2π, length = n)
x = sin.(t)
y = cos.(t)

anim = @animate for i ∈ 1:n
    circleplot(x, y, i)
gif(anim, "anim_fps15.gif", fps = 15)

Save the code as plot.jl in an empty directory or any directory you want. I save it at /home/browni/LasthrimProjection/

Then I open terminal cd to that directory and type:

julia --project="."

julia> ]

pkg> add Plots

julia> include("plot.jl")

(in case you haven’t know create a new environment is better to manage packages in certain project)

There will be no images saved. You can include your animation file like my method above.

If you want to use IJulia / Jupyter Notebook it is more handy you can see the animation directly at the browser.

Hope this will help you.

1 Like

If you use the verbose=true option - gif(anim, "anim_fps15.gif", fps = 15, verbose=true) - you’ll see where on disk the images are saved.


Thanks @cormullion for the info.

If there is an option inside gif() function to not saving images, it would help @qwerty a lot

1 Like