# Stuck in slider tutorial and don't know why (GLMakie)

**URL:** https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737
**Category:** New to Julia
**Tags:** question, plotting, glmakie
**Created:** [May 12, 2023, 12:23pm UTC](https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737 "2023-05-12T12:23:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![llovalin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/llovalin/32/44298_2.png) [@llovalin](https://discourse.julialang.org/u/llovalin)
#### Post date: [May 12, 2023, 12:23pm UTC](https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737/1 "2023-05-12T12:23:29Z")

</div>

I’m trying to recreate the tutorial from “doggo dot jl” [Youtube: [02x10] GLMakie Interactive Widgets: Sliders, Buttons & Menus ](https://www.youtube.com/watch?v=odpoatozNz8&list=PLhQ2JMBcfAsjZTA8_jGhz3BVqYgOeyyeu&index=10)

But im stuck at the labelslidergrid! function()  
I get the error message: ERROR: MethodError: no method matching length(::Observable{Any})

even the example from the help through that error:

```julia
  ls = labelslidergrid!(scene, ["Voltage", "Ampere"], Ref(0:0.1:100); format = x -> "$(x)V")
  layout[1, 1] = ls.layout

```

So i dont know what i’m doing wrong.

I’m using Julia 1.9.0 in VScode v1.78.2

and there ist the tutorial code:

```julia
using GLMakie
GLMakie.activate!()

################################################################################
# Sliders
################################################################################

# initialize plot

fig = Figure(resolution = (3840, 2160))

# add axis

ax1 = fig[1, 1] = Axis(fig,
    # borders
    aspect = 1,
    # title
    title = "Sliders Tutorial",
    titlegap = 48, titlesize = 60,
    # x-axis
    xautolimitmargin = (0, 0), xgridwidth = 2, xticklabelsize = 36,
    xticks = LinearTicks(20), xticksize = 18,
    # y-axis
    yautolimitmargin = (0, 0), ygridwidth = 2, yticklabelpad = 14,
    yticklabelsize = 36, yticks = LinearTicks(20), yticksize = 18
)

# darken axes

vlines!(ax1, [0], linewidth = 2)
hlines!(ax1, [0], linewidth = 2)

lsgrid = labelslidergrid!(fig,
    ["scale", "x-reference", "y-reference"], #edited from original
    Ref(LinRange(-10:0.01:10));
    formats = [x -> "$(round(x, digits = 2))"],
    labelkw = Dict([(:fontsize, 30)]),
    sliderkw = Dict([(:linewidth, 24)]),
    valuekw = Dict([(:fontsize, 30)])
)

# set starting position for slope

set_close_to!(lsgrid.sliders[1], 1.0)

# layout sliders

sl_sublayout = GridLayout(height = 150)
fig[2, 1] = sl_sublayout
fig[2, 1] = lsgrid.layout

# draw a function

x = -10:0.01:10
m = @lift($scale .* x.^2) #quadratic function #edited from original
line1 = lines!(ax1, x, m, color = :blue, linewidth = 5) #edited from original

# create listeners

scale = lsgrid.sliders[1].value #edited from original
xreference = lsgrid.sliders[2].value #edited from original
yreference = lsgrid.sliders[3].value #added 

# xreference, yreference are Float32s
# but for arrows! below we need vectors of Float32s, so we promote them here

# arrow base points
xbase = @lift([$xreference])
ybase = @lift([$yreference])

#new multi-variable scalar-valued functions
p(x,y,scale) = (x + scale * y-1)^2/(scale^2) #added
z(x,y,scale) = cbrt(-p(x,y,scale)/2) #added

# arrow head points
# note: here we also return vectors
xhead = lift(xreference, yreference, scale) do x, y, s
    return [x/1 + 2*s * z(x,y,s)]
end
yhead = lift(xreference, yreference, scale) do x, y, s
    return [y + z(x,y,s)]
end

arrows!(ax1, xbase, ybase, xhead, yhead)

display(fig)

```

PS: I knwo they changed the textsize to fontsize. Is there somthing else importent it missed to change?

---

<div class="post-metadata">

### Author: ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)
#### Post date: [May 12, 2023, 1:11pm UTC](https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737/2 "2023-05-12T13:11:42Z")

</div>

I think I answered a question regarding the same tutorial already here: [GLMakie beginners help: Multiple sliders and an arrow - #3 by fatteneder](https://discourse.julialang.org/t/glmakie-beginners-help-multiple-sliders-and-an-arrow/92113/3)

Does this fix the issues?

EDIT: Nevermind, you seem to already have found that answer before posting your question …

---

<div class="post-metadata">

### Author: ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)
#### Post date: [May 12, 2023, 2:22pm UTC](https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737/3 "2023-05-12T14:22:42Z")

</div>

Right now I am on version `GLMakie@v0.8.4` and there it says that `labelslidergrid!` is deprecated, one should use `SliderGrid` instead. So maybe try replacing that part with

```julia
lsgrid = SliderGrid(fig[2,1],
    (label = "scale", range = LinRange(-10:0.01:10), format = x -> "$(round(x, digits = 2))"),
    (label = "x-reference", range = LinRange(-10:0.01:10), format = x -> "$(round(x, digits = 2))"),
    (label = "y-reference", range = LinRange(-10:0.01:10), format = x -> "$(round(x, digits = 2))")
)

```

Fontsize should now be added to `Figure`, but for some reason it does not scale the label’s sizes for me at the moment (although I have another script where it still works …).

Also: These two blocks need to be swapped in the script, because `scale` needs to be defined first before one can listen to it:

```julia
# create listeners

scale = lsgrid.sliders[1].value #edited from original
xreference = lsgrid.sliders[2].value #edited from original
yreference = lsgrid.sliders[3].value #added 

```

```julia
# draw a function

x = -10:0.01:10
m = @lift($scale .* x.^2) #quadratic function #edited from original
line1 = lines!(ax1, x, m, color = :blue, linewidth = 5) #edited from original

```

---

<div class="post-metadata">

### Author: ![llovalin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/llovalin/32/44298_2.png) [@llovalin](https://discourse.julialang.org/u/llovalin)
#### Post date: [May 12, 2023, 8:01pm UTC](https://discourse.julialang.org/t/stuck-in-slider-tutorial-and-dont-know-why-glmakie/98737/4 "2023-05-12T20:01:02Z")

</div>

A big thanks to you. I have not noticed that.  
Now it works. Nice!
