# Cannot set linestyle to :solid with observable using GLMakie

**URL:** <https://discourse.julialang.org/t/cannot-set-linestyle-to-solid-with-observable-using-glmakie/111413>\
**Category:** Visualization\
**Tags:** glmakie\
**Created:** [March 10, 2024, 8:06am UTC](https://discourse.julialang.org/t/cannot-set-linestyle-to-solid-with-observable-using-glmakie/111413 "2024-03-10T08:06:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oniehuis](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oniehuis](https://discourse.julialang.org/u/oniehuis)\
**Post date:** [March 10, 2024, 8:06am UTC](https://discourse.julialang.org/t/cannot-set-linestyle-to-solid-with-observable-using-glmakie/111413/1 "2024-03-10T08:06:55Z")

</div>

I want to change the linestyle of lines in an axis using an observable for the linestyle. When using the little code snippet below, it works for setting the linestyle to :dot, :dash, :dotdash, but not for setting the linestyle to :solid. Is this intentional or a bug? When I misspell a linestyle symbol, I get an error that lists :solid as a valid linestyle option (i.e., ERROR: Unknown linestyle: dotdash. Available line styles are: :solid, :dash, :dot, :dashdot, :dashdotdot, or a sequence of numbers enumerating the next transparent/opaque region. …). If this is not a bug, how would I have to change the code to change the linestyle of the line after it is inserted into the axis?

I ran the code with Julia v1.10.2 and GLMakie v0.9.9.

```using

f = Figure()
ax = Axis(f[1, 1])
display(f)

ls = Observable{Symbol}(:dot)
lines!(ax, 1:100, rand(100), linestyle=ls)

ls[] = :dash # ok
ls[] = :dashdot # ok
ls[] = :dashdotdot # ok
ls[] = :solid # ERROR

ERROR: MethodError: Cannot `convert` an object of type Nothing to an object of type Vector{Float32}

Closest candidates are:
  convert(::Type{Array{T, N}}, ::StaticArraysCore.SizedArray{S, T, N, N, Array{T, N}}) where {S, T, N}
   @ StaticArrays ~/.julia/packages/StaticArrays/EHHaF/src/SizedArray.jl:88
  convert(::Type{Array{T, N}}, ::StaticArraysCore.SizedArray{S, T, N, M, TData} where {M, TData<:AbstractArray{T, M}}) where {T, S, N}
   @ StaticArrays ~/.julia/packages/StaticArrays/EHHaF/src/SizedArray.jl:82
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  ...

Stacktrace:
  [1] setproperty!(x::Observable{Vector{Float32}}, f::Symbol, v::Nothing)
    @ Base ./Base.jl:40
  [2] setindex!(observable::Observable, val::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:122
  [3] (::Observables.MapCallback)(value::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:436
  [4] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
  [5] invokelatest
    @ ./essentials.jl:889 [inlined]
  [6] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
  [7] setindex!(observable::Observable, val::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123
  [8] (::Observables.SetindexCallback)(x::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:148
  [9] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [10] invokelatest
    @ ./essentials.jl:889 [inlined]
 [11] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [12] setindex!(observable::Observable, val::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123
 [13] top-level scope
    @ ~/Desktop/test.jl:19

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [March 10, 2024, 8:49am UTC](https://discourse.julialang.org/t/cannot-set-linestyle-to-solid-with-observable-using-glmakie/111413/2 "2024-03-10T08:49:16Z")

</div>

Looks like a bug, the type parameterization of one observable is too strict. Could you open an issue?

---

<div class="post-metadata">

**Author:** ![oniehuis](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oniehuis](https://discourse.julialang.org/u/oniehuis)\
**Post date:** [March 10, 2024, 10:05am UTC](https://discourse.julialang.org/t/cannot-set-linestyle-to-solid-with-observable-using-glmakie/111413/3 "2024-03-10T10:05:04Z")

</div>

Thank you for your feedback. I have opened an issue.
