I’m trying to generate an animation with multiple observables as in the following code:
using GLMakie
# Define some sample data (replace with your actual data)
x = range(0.0, 2.0, length=101)
data1 = Observable(sin.(2*x))
data2 = Observable(cos.(3*x))
data3 = Observable(sin.(4*x))
# Define the animation function (replace with your logic)
function update_data(frame)
# Simulate some data update for animation (adjust as needed)
data1 = sin.(2*x .+ frame * 0.1)
data2 = cos.(3*x .- frame * 0.3)
data3 = sin.(4*x)
return data1, data2, data3
end
# Create the plot and initial scatter objects
fig = Figure()
ax = Axis(fig[1,1],
title = "Stacked Scatter Plots",
xlabel = "X",
ylabel = "Y"
#aspect = DataAspect()
)
# Initial scatter plots with transparency for stacking effect
scatter1 = scatter!(ax, x, data1, label="Data 1", color=:red, alpha=0.7)
scatter2 = scatter!(ax, x, data2, label="Data 2", color=:blue, alpha=0.7)
scatter3 = scatter!(ax, x, data3, label="Data 3", color=:green, alpha=0.7)
# Animation loop with stacking and update
nframes = 100
record(fig, "misc/stacked_scatter.mp4", 1:nframes; framerate=25) do frame
# Update data for animation
data1, data2, data3 = update_data(frame)
end
But I the resulting animation only shows the initial state. Please show me where I went wrong?