情节基本示例显示 jupyter 实验室中没有情节

blo*_*ley 5 python plotly jupyter-notebook

我只是尝试在 jupyter notebook 中离线使用 plotly(使用 jupyter lab)。该文档给出了这样的例子:

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")
})
Run Code Online (Sandbox Code Playgroud)

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

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

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

它是 2.7.0 版。

dej*_*ich 4

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

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