【发布时间】:2018-06-15 05:44:37
【问题描述】:
想知道是否有人可以帮助弄清楚为什么这个桑基图不起作用。我很确定我遵循了正确的语法和约定来使用该模块。因为这个,我一直把头撞在桌子上。
import plotly.offline
data_trace = {'domain': {'x': [0, 1], 'y': [0, 1]},
'height': 772,
'link': {'label': ['EM', 'GWF9C51E', 'GWF9C511', 'GWF9C51E Sensor Set',
'GWF9C511 Sensor Set'],
'source': [0, 1, 3, 1, 4, 2, 0, 2],
'target': [1, 3, 1, 0, 2, 0, 2, 4],
'value': [40, 76, 29, 86, 30, 75, 41, 65]},
'node': {'color': ['blue', 'yellow', 'yellow', 'green', 'green'],
'label': ['EM', 'GWF9C51E', 'GWF9C511', 'GWF9C51E Sensor Set',
'GWF9C511 Sensor Set'],
'line': {'color': 'black', 'width': 0.5},
'pad': 15,
'thickness': 15},
'orientation': 'h',
'type': 'sankey',
'valueformat': '.3s',
'valuesuffix': 'pkts',
'width': 1118}
layout = dict(
title = "Testing Sankey",
font = dict(
size = 10
)
fig = dict(data=[data_trace], layout=layout)
plotly.offline.plot(fig, validate=False)
【问题讨论】:
-
你能看一下这篇文章吗,问题出在你的数据上,read more
-
谢谢。我现在知道了。我不得不想另一种方式来表示 Source: 0 -> Target: 1 和 Source: 1 -> Target: 0。可能只是分开发送/接收节点。
-
不客气,一旦你弄清楚了,就把解决方案作为你问题的答案发布,桑基图上没有太多细节!谢谢!
-
会的!现在可以工作了。再次感谢。
-
再次抱歉,您需要打绿色勾以关闭您的答案:)
标签: python python-3.x plotly sankey-diagram