I have been struggling with this for days, I don’t know if this is a bug or if I’m just missing something.
I want to animate both text and and scatters based on real-time input. I’m using Node for this (Observables). This works fine for text, but not for scatter (or lines). I hope my code is understandable:
module Animate
export doAnimate
using Makie
scene = Scene(resolution = (500,500))
attrs = String[]
posX = []
posY = []
function doAnimate(woord,fitness)
newPosX = rand(1:200)
newPosY = rand(1:200)
global attrs
global posX
global posY
cur = 0
for i = 1:length(attrs)
if(attrs[i] == woord)
cur = i
end
end
if (cur>0)
oldPosX = posX[cur][]
oldPosY = posY[cur][]
xStep = (newPosX - oldPosX) / 30
yStep = (newPosY - oldPosY) / 30
for i = 1:30
push!(posX[cur], oldPosX + xStep * i)
push!(posY[cur], oldPosY + yStep * i)
sleep(1/30)
display(scene)
end
else
push!(posX, Node(0.0))
push!(posY, Node(0.0))
s = scatter!([posX[end]], [posX[end]], color = :blue)
t = text!(scene, "fgdsg", position = (posX[end], posY[end]))
push!(attrs, woord)
end
return
end
end
The problem lies with the following line:
s = scatter!([posX[end]], [posX[end]], color = :blue)
It gives me the following error:
ERROR: LoadError: MethodError: no method matching push!(::Annotations{...}, ::Array{String,1}, ::Tuple{Int64,Float64}; rotation=0.0, textsize=0.059999995f0, align=(:center, :top), color=:black, font="Dejavu Sans")
Anyone understands what’s going on?