python-plotly.offline.iplot在Jupyter Notebook / Lab中提供了一个大的空白字段作为其输出
作者:互联网
我正在尝试在Jupyter笔记本中创建Sankey图表,并将代码基于the first example shown here.
最后,我可以运行该程序而不会出现任何错误:
import numpy as npy
import pandas as pd
import plotly as ply
ply.offline.init_notebook_mode(connected=True)
df = pd.read_csv('C:\\Users\\a245401\\Desktop\\Test.csv',sep=';')
print(df.head())
print(ply.__version__)
data_trace = dict(
type='sankey',
domain = dict(
x = [0,1],
y = [0,1]
),
orientation = "h",
valueformat = ".0f",
node = dict(
pad = 10,
thickness = 30,
line = dict(
color = "black",
width = 0.5
),
label = df['Node, Label'].dropna(axis=0, how='any'),
color = df['Color']
),
link = dict(
source = df['Source'].dropna(axis=0, how='any'),
target = df['Target'].dropna(axis=0, how='any'),
value = df['Value'].dropna(axis=0, how='any'),
)
)
print(data_trace)
layout = dict(
title = "Test",
height = 772,
width = 950,
font = dict(
size = 10
),
)
print(layout)
fig = dict(data=[data_trace], layout=layout)
ply.offline.iplot(fig, filename='Test')
使用csv文件,如下所示:
Source;Target;Value;Color;Node, Label
0;2;2958.5;#262C46;Test 1
0;2;236.7;#262C46;Test 2
0;2;1033.4;#262C46;Test 3
0;2;58.8;#262C46;Test 4
0;2;5.2;#262C46;Test 5
0;2;9.4;#262C46;Test 6
0;2;3.4;#262C46;Test 7
乍看之下,各种输出看起来似乎运行良好,但是ply.offline.iplot(fig,filename =’Test’)的最终输出仅显示了一个大的空白字段:
运行一次笔记本中的所有单元之后,终端将如下所示:
有人可以指出我在哪里出问题了吗?
>编辑:我也在这个论坛上发布了这个问题:https://community.plot.ly/t/no-output-from-plotly-offline-iplot/8086–
解决方法:
过去,我在Jupyter中使用脱机进行绘图时也遇到过类似的问题-有时/为什么无法显示绘图,这出乎意料地不一致.从增加的数据速率限制开始可能值得尝试.
jupyter笔记本–NotebookApp.iopub_data_rate_limit = 1.0e10
标签:python,jupyter-notebook,jupyter,jupyter-lab,plotly 来源: https://codeday.me/bug/20191010/1886682.html