Hello.
I am facing a problem with Observables (of varying length) in Makie.jl. The problem can be summarised to the following minimal example:
using Makie
#AbstractPlotting.inline!(true) # Uncomment if using Atom and Juno.
# Made up data.
x = rand(10);
y = rand(10);
# Make x_i and y_i depend on the value of the observable i.
i = Node(1); # Initialise observable i to the value of 1.
x_i = lift(t -> x[1:t], i); # The length of x_i and y_i is determined by the value of i.
y_i = lift(t -> y[1:t], i);
scene = Scene(limits = FRect(0.0, 0.0, 2.0, 2.0));
scatter!(scene, x_i, y_i); # A scatter plot with x_i on the x axis and y_i on the y axis.
scene # See a plot with one point, as the observable i has value 1, everything is fine.
push!(i, 2); # Change value of the observable i to 2.
scene # See a plot with two points, everything is fine.
push!(i, 3); # DimensionMismatch("arrays could not be broadcast to common size") ???
Why do I get the error on the last line? To me this does not make any sense, as changing the value of i
to 2 works. I noticed, that if I instead write:
x_i = lift(t -> x[1:t], i);
y_i = lift(t -> y[1:length(t)], x_i);
the error disappears. Hopefully someone can explain what is going on? I was under the impression that multiple values can depend on the same Observable.
My use case is making an animation that plots my data up to time index i.