Hello,
I am using GLMakie to make an interactive plot. I would like to make a label to a slider that shows the actual value of an observable. But how do I extract the value so that it can be rounded and displayed?
In the example below, I have tried with different combinations, but I always get an error (the third print something bu the value never changes).
What is the right syntax?
Thank you
using GLMakie
# starting parameters
x = 0.1
y = 1.6
z = 1.9
p = [x,y,x]
# ranges
x_vals = LinRange(0,10, 10)
y_vals = LinRange(-2,5, 20)
z_vals = LinRange(-10,10, 100)
# Observable
p_mod = Observable(p)
# plot
fig = Figure()
ax = Axis(fig[1,1:2])
# sliders
Label(fig[2,1], string("X value:", round(p_mod[1], digits=2)))
x_sld = Slider(fig[2,2], range=x_vals, startvalue=x)
Label(fig[3,1], string("Y value:", round(y_sld.value, digits=2)))
y_sld = Slider(fig[3,2], range=x_vals, startvalue=x)
Label(fig[4,1], string("Z value:", round(p_mod.val[3], digits=2)))
z_sld = Slider(fig[4,2], range=x_vals, startvalue=x)
# change values
on(x_sld.value) do val
p_mod.val[1] = val
p_mod[] = p_mod[]
end
on(y_sld.value) do val
p_mod.val[2] = val
p_mod[] = p_mod[]
end
on(z_sld.value) do val
p_mod.val[3] = val
p_mod[] = p_mod[]
end