Movie from data

Hi there !

I am new on Julia, so I would appreciate your help.

I have a data set called data :
julia> size(data)
(4994, 50405)
4994 is the distance along an axis and 50405 is the time with :
julia> size(time_test)
(50405,)
julia> size(space_sampling)
(4994,)

I would like to create and record a movie showing the evolution of the data over time. I looked some tutorials online but I don’t see how it works (As I said, I am new…). For vizualizing plots, I usually use GLMakie.

Thanks for your help!
N.

Welcome! I think this is probably the relevant doc. I’d guess in your case it would be:

# data defined beforehand...
using GLMakie

points = Observable(data[:, 1])

fig, ax = scatter(points)
limits!(ax, 1, size(data)[1], 0, max(data...))

frames = 2:(size(data)[2])

record(fig, "animation.mp4", frames;
        framerate = 30) do frame
    points[] = data[:, frame]
end

Thanks! that works great :slight_smile:

Small question !
What should I do to add an dynamic title with the time data :
points = Observable(data[:, 1])
fig, ax = lines(space_sampling,points)
limits!(ax, 0, 15, -500, 1000)
ax.title = “t = $time_test[points]”
frames = 1:200
record(fig, “animation.mp4”, frames;
framerate = 30) do frame
points = data[:, frame]
end

What should I do to add an dynamic title with the time data
You can simply change the title in the function running for each frame:

record(fig, “animation.mp4”, frames;
        framerate = 30) do frame
    points[] = data[:, frame]
    ax.title[] =  "new title for frame $(frame)"
end

(By the way, in this forum you can enclose your code with three backticks ``` and it will format it as Julia code, making it more readable!)

3 Likes