# Interactive Plot with MakieLayout

**URL:** <https://discourse.julialang.org/t/interactive-plot-with-makielayout/48843>\
**Category:** New to Julia\
**Tags:** plotting, makie\
**Created:** [October 22, 2020, 7:43pm UTC](https://discourse.julialang.org/t/interactive-plot-with-makielayout/48843 "2020-10-22T19:43:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bensetterholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bensetterholm/32/12792_2.png) [@bensetterholm](https://discourse.julialang.org/u/bensetterholm)\
**Post date:** [October 22, 2020, 7:43pm UTC](https://discourse.julialang.org/t/interactive-plot-with-makielayout/48843/1 "2020-10-22T19:43:00Z")

</div>

I have been searching for a clear guide or example to making a simple plot + slider gui with MakieLayout. I see how to add sliders in the Makie documentation but not how to make them useful. There are some examples with Makie sliders in the gallery, but these are not clear to me how they work based on the documentation, and it seems to me that the basic Makie sliders are different in behavior from the MakieLayout LSliders as well.

Below is a dummy plot example; what do I have to do to make the slider control the `amp` variable?

```julia
using GLMakie
using AbstractPlotting
using AbstractPlotting.MakieLayout

x = (0:0.01:4) .* π
scene, layout = layoutscene(resolution = (1200, 900))
ax = layout[1, 1] = LAxis(scene)
line1 = lines!(ax, x, 10 * sin.(x))

sl = layout[2, 1] = LSlider(scene, range = 0:0.01:10, startvalue = 3)
amp = sl.value[] # I know this is wrong because amp does not update after assignment

line2 = lines!(ax, x, amp * sin.(x), color=:red) # How to make this line interactive?

scene

```

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [October 23, 2020, 3:52am UTC](https://discourse.julialang.org/t/interactive-plot-with-makielayout/48843/2 "2020-10-23T03:52:45Z")

</div>

Perhaps something like this would work:

```julia
y = lift(s1.value) do v
   v*sin.(x)
end
line2 = lines!(ax, x, y, color=:red)

```

Here, `lift` is basically like map for an observable, meaning the block will trigger every time the `s1.value` updates, and re-create the y-array with the correct value.

---

<div class="post-metadata">

**Author:** ![bensetterholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bensetterholm/32/12792_2.png) [@bensetterholm](https://discourse.julialang.org/u/bensetterholm)\
**Post date:** [October 23, 2020, 2:08pm UTC](https://discourse.julialang.org/t/interactive-plot-with-makielayout/48843/3 "2020-10-23T14:08:58Z")

</div>

Excellent, thank you!
