No problem, and just to give some examples:
in a Jupyter notebook:
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):
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:
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 has a lot of examples as well.