JuliaGizmos / Interact.jl

Interactive widgets to play with your Julia code
Other
522 stars 77 forks source link

Julia: using @manipulate creates plot but doesn't update after saving notebook and reopening #411

Open paulnakroshis opened 2 years ago

paulnakroshis commented 2 years ago

I am totally stumped by the following:

1) I create a plot in Julia 1.6.3 with the current versions of Interact.jl and WebIO.jl and use the @manipulate macro to create a plot with an options box and a slider. The plots works and can be manipulated appropriately as you expect.

2) I am working on MacOS 12.0.1 with the most recent Conda Distribution installed. Here is the code which I use in a jupyterlab notebook:

using Plots
using Interact
using DataStructures
x = y = 0:0.1:30

freqs = OrderedDict(zip(["π/4", "π/2", "3π/4", "π"], [π/4, π/2, 3π/4, π]))
mp = @manipulate for freq1 in freqs, freq2 in slider(0.01:0.1:4π; label="freq2")
    y = @. sin(freq1*x) * sin(freq2*x)
    plot(x, y)
end

This will run in a new notebooks as expected. BUT: save the notebook, restart jupyterlab and open the notebook and then the plot will be created but the interactive aspect will not work. Just to make things even more confusing (but this is likely a huge clue that I am seemingly incapable of using to solve the problem), if you open a blank notebook, copy and paste the code into a cell in that new notebook, it will work!

I've tried this on Safari, Chrome, and Firefox and the same behavior exists.

Can anyone shed light on this? The Interact widgets make Julia such a valuable tool for teaching, and although I could work in Pluto notebooks, I would really like to be able to work is standard Julia notebooks.

UPDATE: (19:39 UTC 12 Nov 2021)

Just checked the code above on PopOS! with Julia 1.6.3. Same problem. First time, it runs and sliders work. Save and quit browser, kill kernel and then restarting jupyter lab resultys in failure: plot is rendered, but sliders no longer update the plots when manipulated.

Thanks in advance. I am stumped.

thegravelinspector commented 2 years ago

The same happens here, but if I 'reload the current page' (Ctrl-R) in firefox, it start working. That helps me for now, and perhaps is a clue for further investigation.

freddy5566 commented 2 years ago

After I uninstall webio_jupyter_extension and re-install it through pip. Chrome works smoothly, but safari just cannot update while I drag the slider.