2

I am trying to run Julia v1.7.3 in google colab, following the set-up instructions from this notebook.

It mostly runs well, but I'm having a ton of trouble getting interactive plots to work. A lot of people seem to have this difficulty as well, as there are lots of different pages online.

The most promising lead I've found is this tutorial from Makie about how to use sliders.

They include the following demo code:

using GLMakie

fig = Figure()

ax = Axis(fig[1, 1])

lsgrid = labelslidergrid!(
    fig,
    ["Voltage", "Current", "Resistance"],
    [0:0.1:10, 0:0.1:20, 0:0.1:30];
    formats = [x -> "$(round(x, digits = 1))$s" for s in ["V", "A", "Ω"]],
    width = 350,
    tellheight = false)

fig[1, 2] = lsgrid.layout

sliderobservables = [s.value for s in lsgrid.sliders]
bars = lift(sliderobservables...) do slvalues...
    [slvalues...]
end

barplot!(ax, bars, color = [:yellow, :orange, :red])
ylims!(ax, 0, 30)

set_close_to!(lsgrid.sliders[1], 5.3)
set_close_to!(lsgrid.sliders[2], 10.2)
set_close_to!(lsgrid.sliders[3], 15.9)

fig

However, when I run this demo code, I get a static image, with the sliders frozen in place!

Does anyone know what I could do to make the sliders actually move in google colab?

  • You should use WGLMakie, which is the Web-based backend. GLMakie will only display a PNG in Jupyter notebooks since it is meant for desktop use. – Anshul Singhvi Jul 03 '22 at 09:08

0 Answers0