I have a diagram in a layout that is changing depending on user input. This means I need to delete the line and change the axis label again and again. What is the best way to do that?
This is my current approach, but it causes problems when used in a layout:
using GLMakie
const objects = []
function plot_sin(fig)
if length(objects) > 0
delete!(objects[end])
end
ax=Axis(fig[1, 1], xlabel = "time [s]", ylabel = "sin")
x = 0:0.1:10*pi
y = sin.(x)
po = lines!(x,y)
push!(objects, ax)
end
function plot_cos(fig)
if length(objects) > 0
delete!(objects[end])
end
ax=Axis(fig[1, 1], xlabel = "time [s]", ylabel = "cos")
x = 0:0.1:10*pi
y = cos.(x)
po = lines!(x,y)
push!(objects, ax)
end
function main(gl_wait=true)
fig=Figure()
@async begin
for i in 0:2
plot_sin(fig)
sleep(2)
plot_cos(fig)
sleep(2)
end
end
gl_screen = display(fig)
if gl_wait
wait(gl_screen)
end
return nothing
end
main()
Any better way?