I want to plot lines!() with Observables as x and y parameters.
The value of the Obervables changes obviously, because I print them to the console.
However, the lines!() plot won’t update:
using GLMakie
x = [[[4, 3], [-4, -3], [-0.75, 2]], [[5, 4], [-7, 8], [2, 2]], [[5, 7], [-2, 1], [9, 10]]]
xs = [Float32.(getindex.(getindex.(x,i),1)[1:end]) for i in 1:3]
ys = [Float32.(getindex.(getindex.(x,i),2)[1:end]) for i in 1:3]
x_trail = Observable(getindex.(xs, [1:1]))
y_trail = Observable(getindex.(ys, [1:1]))
f = Figure()
Axis(f[1, 1])
lines!.(x_trail, y_trail, linewidth = 3)
display(f)
for i in 1:3
x_trail[] = getindex.(xs, [1:i])
y_trail[] = getindex.(ys, [1:i])
println(x_trail[])
println(y_trail[])
sleep(1)
end
Do you have any idea, how to update the plot as x_trail and y_trail are growing, without calling lines!() each iteration? I tried, but:
lines!.(x_trail[], y_trail[], linewidth = 3)
doesn’t do anything, and
lines!.(x_trail, y_trail, linewidth = 3)
gives the error:
ERROR: MethodError: no method matching length(::Observable{Vector{Vector{Float32}}})