jupyter笔记本幻灯片中的情节互动图

发布于 2025-01-29 19:10:13 字数 133 浏览 3 评论 0原文

我正在使用Jupyter Notebook以幻灯片模式(和Rise)构建演示文稿。

一切正常,直到我添加与Plotly添加交互式图为止。我只看到代码,没有图。

是否可以在幻灯片中使用绘图具有交互绘图?

谢谢你!

I'm building a presentation using Jupyter Notebook in slideshow mode (and RISE).

Everything works fine till I add an interactive plot with Plotly. I only see the code, no plot.

Is it possible to have an interactive plot using Plotly in Slideshow?

Thank you!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿! 2025-02-05 19:10:14

只需将此行添加到iplot单元格:

plotly.offline.init_notebook_mode(connected=True)

Just add this line to the iplot cell:

plotly.offline.init_notebook_mode(connected=True)
眼泪淡了忧伤 2025-02-05 19:10:14

以下代码可作为替代方案。

import chart_studio
import chart_studio.plotly as py
import chart_studio.tools as tls
import plotly.graph_objects as go

chart_studio.tools.set_credentials_file(username='/...', api_key='/...')    # Register on chart_Studio website

trace = go.Scatter(
    x=[1, 2, 3],
    y=[4, 5, 6]
)

data = [trace]
layout = go.Layout(title="My Plot")

fig = go.Figure(data=data, layout=layout)

### Now, instead of using iplot(), you can use py.plot() to upload your plots to your chart_studio account
# py.plot(fig, filename = 'my_plot', auto_open=True)

display(fig.show()) 

这是结果:
结果

The following code works as an alternative.

import chart_studio
import chart_studio.plotly as py
import chart_studio.tools as tls
import plotly.graph_objects as go

chart_studio.tools.set_credentials_file(username='/...', api_key='/...')    # Register on chart_Studio website

trace = go.Scatter(
    x=[1, 2, 3],
    y=[4, 5, 6]
)

data = [trace]
layout = go.Layout(title="My Plot")

fig = go.Figure(data=data, layout=layout)

### Now, instead of using iplot(), you can use py.plot() to upload your plots to your chart_studio account
# py.plot(fig, filename = 'my_plot', auto_open=True)

display(fig.show()) 

Here is the result:
Result

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文