You could still use the Observable strategy, if you like:
using GLMakie, Colors
points = Observable(Point2f[])
colors = Observable(RGB[]) # or Float64[] if you use a colormap
fig, ax, plt = scatter(points, color=colors)
xlims!(ax, 0, 1); ylims!(ax, 0, 1)
display(fig)
for i = 1:100
push!(points[], rand(Point2f))
push!(colors[], rand(RGB))
notify(points); notify(colors) # (Note: we need both notify s)
sleep(0.1)
end
# wait(display(fig)) # if you're running this as a script and don't want the window to close
Using
for i = 1:100
points[] = push!(points[], rand(Point2f)) # notifies here alreay
colors[] = push!(colors[], rand(RGB))
sleep(0.1)
end
also seems to work, but this is perhaps* more dangerous concerning the sync issue @jules mentions: what if the plot already gets updated when length(points[]) == length(colors[]) + 1? The manual update! in the latest versions of Makie provides a way to avoid this situation.
*Edit: I’m not sure, but the fact that scatter throws an error if you supply differently sized Vectors, but nothing happens when you only push! to one Observable, might indicate that this is sort of already taken care of by just not updating the plot when the lists go out of sync.