Jupyter笔记本不显示任何图形。.(只是图形)

时间:2020-02-26 10:39:27

标签: python jupyter-notebook plotly

在jupyter笔记本中,我的代码可以运行..仅不显示图形。

我尝试了很多方法。

我的示例代码,图片。

我的代码和图片

import plotly.offline as pyo
import plotly.graph_objs as go
pyo.init_notebook_mode()

trace0 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[5, 8, 2, 7]
)
trace1 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[1, 5, 13, 2]
)
data = [trace0, trace1]
pyo.iplot(data, filename = 'ex')

enter image description here

然后,我单击一个按钮;将图档下载为png ...

下载了newplot.svg;打开文件...

资源管理器

捕获newplot.svg

enter image description here

在新的水龙头浏览器中,此图显示良好。

为什么在jupyter笔记本电脑上却没有显示图形?

以防万一。 添加我的python软件包版本;

  • Python 3.7.4
  • 密谋4.5.2
  • numpy 1.16.6
  • 季节性0.9.0
  • 熊猫0.25.3

2 个答案:

答案 0 :(得分:1)

请参考plotly的getting started documentation ...

要在经典的Jupyter笔记本中使用,请使用pip安装笔记本和ipywidgets软件包...

$ pip install "notebook>=5.3" "ipywidgets>=7.2"

要在JupyterLab中使用,请使用pip安装jupyterlab和ipywidgets软件包...

$ pip install jupyterlab "ipywidgets>=7.5"

然后运行以下命令以安装所需的JupyterLab扩展(请注意,这将需要安装节点):

JupyterLab渲染器支持

jupyter labextension install jupyterlab-plotly@4.13.0

可选:Jupyter小部件扩展

jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.13.0

答案 1 :(得分:0)

我的方法是Jupyter Notebook默认程序(Explore-> Chrome)