Creating an animation with data from dataframe using GLMakie?

Here is a simple example:

using DataFrames
using GLMakie

df = DataFrame(x = 1:100, y = 1:100)

# plot a line
lines(df.x, df.y)

# create an Observable object which stores a point's coordinate
p = Observable(Point2f(NaN, NaN))

# plot the point
scatter!(p, color=(:yellow, 0.5), strokecolor=:red, strokewidth=1)

# now update the Observable p will update the position of the point in the figure
for i in 1:100
    p[] = Point2f(df.x[i], df.y[i])
    sleep(0.1)
end

2 Likes