在Colab中的朱莉娅(Julia)制作互动情节

发布于 2025-02-03 17:55:47 字数 1055 浏览 5 评论 0原文

我正在尝试在Google Colab中运行Julia v1.7.3 Noreferrer“>此笔记本中的设置说明。

它的运行良好,但是我遇到了很大的麻烦。许多人似乎也有这个困难,因为在线上有很多不同的页面。

我发现的最有希望的领导是来自Makie的教程滑块。

它们包括以下演示代码:

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

但是,当我运行此演示代码时,我会得到一个静态图像,而滑块冻结了!

有谁知道我该怎么做才能使滑块实际上在Google Colab中移动?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文