简体   繁体   English

Jupyter Notebookly 没有显示图表..(只是图表)

[英]Jupyter notebook plotly not showing graph.. (just graph)

In jupyter notebook, My code do run.. just not showing graph.在 jupyter notebook 中,我的代码确实运行了……只是没有显示图表。

I have tried many way..我试过很多方法..

My example code, picture.我的示例代码,图片。

My Code & picture我的代码和图片

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在此处输入图片说明

And, I click a button;而且,我点击了一个按钮; Download plot as png...下载图为png...

downloaded newplot.svg;下载 newplot.svg; open a file...打开一个文件...

explorer探险家

Capture newplot.svg捕获 newplot.svg

enter image description here在此处输入图片说明

In new tap explorer, This graph show well.在新的水龙头资源管理器中,此图显示良好。

why in jupyter notebook poltly not showing graph?为什么在 jupyter notebook 中不显示图表?

Just in case version.以防万一版本。 Add my python package version;添加我的python包版本;

  • Python 3.7.4蟒蛇 3.7.4
  • plotly 4.5.2情节 4.5.2
  • numpy 1.16.6麻木 1.16.6
  • seaborn 0.9.0海生 0.9.0
  • pandas 0.25.3熊猫 0.25.3

please refer to plotly's getting started documentation ...请参阅 plotly 的入门文档...

For use in the classic Jupyter Notebook, install the notebook and ipywidgets packages using pip...要在经典的 Jupyter Notebook 中使用,请使用 pip 安装 notebook 和 ipywidgets 包...

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

For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip...要在 JupyterLab 中使用,请使用 pip 安装 jupyterlab 和 ipywidgets 包...

$ pip install jupyterlab "ipywidgets>=7.5"

Then run the following commands to install the required JupyterLab extensions (note that this will require node to be installed):然后运行以下命令来安装所需的 JupyterLab 扩展(请注意,这将需要安装节点):

JupyterLab renderer support JupyterLab 渲染器支持

jupyter labextension install jupyterlab-plotly@4.13.0

OPTIONAL: Jupyter widgets extension可选:Jupyter 小部件扩展

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

我的方法是 Jupyter notebook 默认程序(Exploere -> Chrome)

# Import the necessaries libraries
import plotly.offline as pyo
import plotly.graph_objs as go
# Set notebook mode to work in offline
pyo.init_notebook_mode()
# Create traces
trace0 = go.Bar(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = go.Bar(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
# Fill out data with our traces
data = [trace0, trace1]
# Plot it and save as basic-line.html
pyo.plot(data, filename = 'Test-bar.html', auto_open = False)

# Show HTML
from IPython.display import HTML
HTML(filename='Test-bar.html')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM