Python绘出的Sankey图形未显示

Python绘出的Sankey图形未显示,python,python-3.x,plotly,sankey-diagram,Python,Python 3.x,Plotly,Sankey Diagram,我想知道是否有人能帮我弄清楚为什么这个Sankey图表不起作用。我非常确定我遵循了正确的语法和约定来使用该模块。因为这件事,我的头一直撞在桌子上 import plotly.offline data_trace = {'domain': {'x': [0, 1], 'y': [0, 1]}, 'height': 772, 'link': {'label': ['EM', 'GWF9C51E', 'GWF9C511', 'GWF9C51E Sensor Set',

我想知道是否有人能帮我弄清楚为什么这个Sankey图表不起作用。我非常确定我遵循了正确的语法和约定来使用该模块。因为这件事,我的头一直撞在桌子上

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)
问题是:

         'source': [1, 3],
         'target': [3, 1]
您不能让源和目标扮演双重角色,即:节点1既是源又是目标

根据您的用例,您可能需要将其拆分


对于我来说,这是一个网络产品,因此我将节点分为“RX”和“TX”,这样我就不会将源/目标数据列表加倍。

你能阅读这篇文章吗,问题在于你的数据,谢谢。我现在明白了。我必须想另一种方法来表示源:0->目标:1和源:1->目标:0。可能只是分开发送/接收节点。不客气,一旦你弄明白了,就把解决方案作为问题的答案发布出来。sankey图表上也没有太多细节!谢谢行!现在开始工作了。再次感谢。再次抱歉,您需要打绿色勾以关闭您的答案:)