Skip to content

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

@paulnakroshis

Description

@paulnakroshis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions