gpt4 book ai didi

python - plotly 基本示例显示 jupyter 实验室中没有 plotly

转载 作者:行者123 更新时间:2023-12-03 16:04:37 24 4
gpt4 key购买 nike

我只是尝试在 jupyter notebook 中离线使用 plotly(使用 jupyter lab)。 docs给出这个例子:

import plotly
import plotly.graph_objs as go

plotly.offline.init_notebook_mode(connected=True)

plotly.offline.iplot({
"data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
"layout": go.Layout(title="hello world")
})

我试过了,在 Edge 或 Firefox 中都没有显示图表。
笔记本中制作了一个输出单元格,但没有图表。

如果我使用 plotly.offline.plot 而不是 iplot,它会起作用。如果我使用传统的 jupyter notebook 而不是 jupyter lab,它会起作用。

任何想法为什么它不显示?

它是 2.7.0 版。

最佳答案

您是否安装了 Plotly JupyterLab 扩展?没有它,它将无法内联工作。你可以在这里得到它:https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension

或者直接通过终端安装:jupyter labextension install @jupyterlab/plotly-extension

关于python - plotly 基本示例显示 jupyter 实验室中没有 plotly ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51264181/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com