Plot Animations

The Plot library can be used for animations. The following is copied from the documentation.


            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]
            end
            
            n = 150
            t = range(0, 2pi, length = n)
            x = sin.(t)
            y = cos.(t)
            
            anim = @animate for i in 1:n
                circleplot(x, y, i)
            end
            gif(anim, "anim_fps15.gif", fps = 15)
            

The result is:

A key feature here is the use of circshift. This rotates the data around in an array.