plotly basic example shows no plot in jupyter lab(plotly 基本示例显示 jupyter 实验室中没有绘图)
问题描述
我只是尝试在 jupyter notebook 中离线使用 plotly(使用 jupyter lab).docs 给出了这个例子:
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")
})
我试过了,在 Edge 或 Firefox 中都没有显示图表.
在 notebook 中制作了一个输出单元格,但没有图表.
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.
如果我使用 plotly.offline.plot 而不是 iplot,它会起作用.如果我使用传统的 jupyter notebook 而不是 jupyter lab,它就可以工作.
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?
这是情节版本 2.7.0.
It's plotly version 2.7.0.
推荐答案
你安装 Plotly JupyterLab 扩展了吗?没有它,它将无法内联工作.你可以在这里得到它:https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension
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
或者直接通过终端安装:jupyter labextension install @jupyterlab/plotly-extension
or just install via terminal: jupyter labextension install @jupyterlab/plotly-extension
这篇关于plotly 基本示例显示 jupyter 实验室中没有绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:plotly 基本示例显示 jupyter 实验室中没有绘图
基础教程推荐
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
