I’m trying to make a menu in Makie which changes the plot. Basically this:
using GLMakie
fig = Figure()
menu = Menu(fig, options = [1,2])
fig[1, 1] = vgrid!(
Label(fig, "Index a", width = nothing),menu;
tellheight = false, width = 200)
ax = LScene(fig[1, 2])
a = Node{Int}(1)
function my_function(a,x)
data = [sin.(pi*x), cos.(pi*x)]
return data[a]
end
xplot = LinRange(-1,1,100)
yplot = @lift my_function($a,xplot)
plt = scatter!(ax, xplot, yplot)
on(menu.selection) do s
a[] = s
end
fig
except that my actual my_function
returns multiple outputs
function my_function(a,x)
data = [sin.(pi*x), cos.(pi*x)]
other_stuff = rand()
return data[a],other_stuff
end
Node and @lift
don’t seem to work for this setting (I get ERROR: LoadError: MethodError: no method matching iterate(::Observable{Tuple{Vector{Float64}, Float64}})
). Is there a way around this?