# How to make dynamic plots with slider bars

**URL:** <https://discourse.julialang.org/t/how-to-make-dynamic-plots-with-slider-bars/30698>\
**Category:** Visualization\
**Created:** [November 4, 2019, 2:19pm UTC](https://discourse.julialang.org/t/how-to-make-dynamic-plots-with-slider-bars/30698 "2019-11-04T14:19:51Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [November 4, 2019, 3:12pm UTC](https://discourse.julialang.org/t/how-to-make-dynamic-plots-with-slider-bars/30698/4 "2019-11-04T15:12:30Z")

</div>

No problem, and just to give some examples:

in a Jupyter notebook:

```julia
using Interact, Plots
## Interact.WebIO.install_jupyter_nbextension() # might be helpful if you see `WebIO` warnings in Jupyter
@manipulate throttle=.05 for λ=0:.1:5, μ=0:.1:5
    xs = range(0.0, 1.0, length = 100)
    Plots.plot(xs, x -> λ*x^2 + μ)
end

```

or with Mux (a webserver):

```julia
using Interact, Plots, Mux
mp = @manipulate throttle=.05 for λ=0:.1:5, μ=0:.1:5
    xs = range(0.0, 1.0, length = 100)
    Plots.plot(xs, x -> λ*x^2 + μ)
end
ui = dom"div"(mp)
WebIO.webio_serve(page("/", req -> ui), 8001)

```

then go to `localhost:8001` in a web browser.

or with Makie:

```julia
using Makie

λ_slider = Makie.slider(0:.1:5, label="λ", raw = true, camera=campixel!, start=1.0);
μ_slider = Makie.slider(0:.1:5, label="μ", raw = true, camera = campixel!);
xs = range(0.0, 1.0, length = 100)

ys = lift(λ_slider[end][:value], μ_slider[end][:value]) do λ, μ
    [λ*x^2 + μ for x in xs]
end

plt = Makie.plot(xs, ys);
scene = Makie.hbox(plt, Makie.vbox(λ_slider, μ_slider), parent=Scene(resolution = (800, 800)))

```

Note it’s probably a good idea to have separate sessions for using Plots + Interact vs Makie since they export things with the same name (`plot`, `slider`, `vbox`, etc), or just qualify everything as I did here (e.g. `Makie.plot`). These were adapted from some code I had from ~6 months ago, and there might be better ways to do the Makie code in particular. The [Makie gallery](http://juliaplots.org/MakieReferenceImages/gallery/index.html) has a lot of examples as well.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-make-dynamic-plots-with-slider-bars/30698)._
