# Makie - Weird error with Observables

**URL:** https://discourse.julialang.org/t/makie-weird-error-with-observables/57960
**Category:** Visualization
**Tags:** makie
**Created:** [March 25, 2021, 6:21pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960 "2021-03-25T18:21:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [March 25, 2021, 6:21pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/1 "2021-03-25T18:21:15Z")

</div>

## Intro

Hello!!

I am having trouble creating a complete Makie scene that does what I want, because it errors:

```julia
ERROR: MethodError: no method matching gl_convert(::String)

```

I’ll explain what I want first, and then the pieces of code that I have written that (try to) implement it.

## What I want

I want to have a scene that contains:

- 1 general title
- 3 subplots
- 1 toggle
- 1 slider

The _slider_ controls which set of data is chosen. Suppose I have a 1000×3×25 `Float64` array. Then the slider controls which set of 1000×3 will be plot (one vector in each subplot).

The _toggle_ will control, in a future, the way the data is displayed. Instead of `Float64`, there will be complex quantities, and the toggle will select if the modulus is plot or only the real part.

## What I have coded

See the 4th post: [Makie - Weird error with Observables - #4 by nandoconde](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/4)

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 25, 2021, 6:29pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/2 "2021-03-25T18:29:45Z")

</div>

Can you post a minimal working example (MWE) that I can execute and debug?

---

<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 25, 2021, 7:48pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/3 "2021-03-25T19:48:54Z")

</div>

What is the variable `freqs`? You have basically left out the most important part 🙂 The arguments of the plotting function that errors.

---

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [March 26, 2021, 10:07am UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/4 "2021-03-26T10:07:49Z")

</div>

Sorry, I thought the code above was clear enough to guess the rest of the variables.  
Here is the state of my packages:

```nohighlight
(@v1.6) pkg> st GLMakie
      Status `~\.julia\environments\v1.6\Project.toml`
  [e9467ef8] GLMakie v0.1.27

(@v1.6) pkg> st Colors
      Status `~\.julia\environments\v1.6\Project.toml`
  [5ae59095] Colors v0.12.6

```

And here is a full MWE:

> **Summary**
>
> ```julia
> # Load packages
> using GLMakie, Colors
> 
> # Data
> freqs = range(5e8, 4.5e10, length = 1001);
> lr = range(0.01, 2π, length = 1001);
> S = Array{Complex,3}(undef, 1001, 3, 25);
> for i = 1:25
> S[:,1,i] = @. (50 - 50*exp(im*lr*i/12))/(50 + 50*exp(im*lr*i/12))
> S[:,2,i] = @. (50 - 75*exp(im*lr*i/12))/(50 + 75*exp(im*lr*i/12))
> S[:,3,i] = @. (50 - 35*exp(im*lr*i/12))/(50 + 35*exp(im*lr*i/12))
> end
> 
> # Figure
> titles = ["S₁₁","S₁₂","S₂₂"]
> res = (1920*0.9, 1080*0.5) # Pixel size
> fig = Figure(resolution = res)
> for i = 1:3
> fig[1,i] = Axis(fig,
> title = titles[i],
> xminorticksvisible = true,
> yminorticksvisible = true,
> xminorgridvisible = true,
> yminorgridvisible = true,
> xminorticks = IntervalsBetween(4),
> yminorticks = IntervalsBetween(4),
> xlabel = "f [GHz]",
> ylabel = "dB")
> end
> linkaxes!(contents(fig[1,1])[1], contents(fig[1,2])[1], contents(fig[1,3])[1])
> ylims!(contents(fig[1,1])[1], (-50, 0))
> fig[0,:] = Label(fig, "Default title", textsize = 30)
> 
> # Interactivity
> fig[3,:] = Slider(fig, range = 1:25, startvalue = 1)
> p = contents(fig[3,:])[1].value
> toggle = Toggle(fig, active = true)
> 
> # Create labels (static)
> lin_label = Label(fig, "lin")
> dB_label = Label(fig, "dB")
> 
> # Display labels and toggle
> fig[2,4] = grid!(hcat(lin_label,toggle,dB_label), tellheight = false)
> 
> # Try to plot figures
> labels = ["CST","CST","CST"]
> colores = [RGB(0.85, 0.325, 0.098), RGB(0, 0.447, 0.741)]
> indices = [CartesianIndex(1,1),CartesianIndex(1,2),CartesianIndex(2,2)]
> dB = x -> (20*log10(abs(x)))
> for i in 1:3
> lines!(fig[2,i], 
> freqs, 
> dB.(S[:,i,1]),
> label = labels[i],
> ylabel = "dB",
> color = colores)
> end
> 
> ```

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 26, 2021, 12:46pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/5 "2021-03-26T12:46:10Z")

</div>

> [@nandoconde](#):
>
> Sorry, I thought the code above was clear enough to guess the resto of the variable

If one only has a few minutes to look into a bug, guessing some variables makes the difference between being able to debug something, or just ignoring the bug report

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 26, 2021, 12:49pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/6 "2021-03-26T12:49:50Z")

</div>

> [@nandoconde](#):
>
> `lines!(fig[2,1], freqs, prueba)`

The mwe works, but the line that errors isn’t included

---

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [March 26, 2021, 1:15pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/7 "2021-03-26T13:15:13Z")

</div>

I have removed the original code that I posted because it was a very bad try to make a MWE. The valid MWE is the one I have posted in the 4th post.

> [@sdanisch](#):
>
> The mwe works, but the line that errors isn’t included

I am surprised that it runs for you. I have copypasted the code I wrote here in the 4th post to my Julia 1.6.0 REPL and it errors. I have recorded a video where I literally copypaste it into a newly created REPL. I could post it here if it helps, but I don’t know how to do that.

I am a bit lost right now 😅

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 26, 2021, 2:34pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/8 "2021-03-26T14:34:18Z")

</div>

Ok, funny, it doesn’t reproduce in VSCode but in the repl! Nevermind then 😉

---

<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 26, 2021, 4:08pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/9 "2021-03-26T16:08:25Z")

</div>

Oh I remember something, I got the same error with label = “some string” before I excluded the label keyword from conversion in GLMakie. Maybe your version is just too old, it’s definitely not the latest from the 0.1 range

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 26, 2021, 5:21pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/10 "2021-03-26T17:21:34Z")

</div>

> [@nandoconde](#):
>
> ```julia
> lines!(fig[2,i], 
> freqs, 
> dB.(S[:,i,1]),
> label = labels[i],
> ylabel = "dB",
> color = colores)
> 
> ```

So there is no `ylabel` for lines - you need to do `axis = (ylabel = ...,))`!

```julia
for i in 1:3
    lines!(fig[2,i], 
        freqs, 
        dB.(S[:,i,1]),
        label = labels[i],
        axis = (ylabel="dB",),
        color = colores[1])
end

```

Note, that `colores` is a 2 element array while `dB.(S[:,i,1])` is a 1001 element array… You need either 1 color per line, or 1 color per coordinate!  
The errors are pretty horrible though - I think that may just be one of the next projects to improve in Makie!

---

<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 26, 2021, 5:44pm UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/11 "2021-03-26T17:44:48Z")

</div>

But you can’t set the ylabel when plotting into an existing axis. Only the plotting functions without ! that create a new axis take axis parameters.

---

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [March 29, 2021, 11:17am UTC](https://discourse.julialang.org/t/makie-weird-error-with-observables/57960/12 "2021-03-29T11:17:03Z")

</div>

Thanks! This solved it. I have more questions, but I will post them in a different thread because they are unrelated to this exact problem.
