plotly basic example shows no plot in jupyter lab

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:41:42

问题


I just tried to use plotly offline in a jupyter notebook (using jupyter lab). The docs gives this example:

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")
})

I tried it and there is no chart displayed, either in Edge or Firefox.
An output cell is made in the notebook, but there is no chart.

It works if I use plotly.offline.plot rather than iplot. It works if I use the traditional jupyter notebook rather than jupyter lab.

Any ideas why it does not display?

It's plotly version 2.7.0.


回答1:


Have you installed Plotly JupyterLab extension? It will not work inline without it. You can get it here: https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension

or just install via terminal: jupyter labextension install @jupyterlab/plotly-extension



来源:https://stackoverflow.com/questions/51264181/plotly-basic-example-shows-no-plot-in-jupyter-lab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!