2

Was wondering if anyone can help figure out why this Sankey diagram is not working. I am pretty sure I followed the proper syntax and conventions to use the module. Been banging my head on the table because of this.

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)
Icee
  • 85
  • 9

1 Answers1

2

The problem is this:

         'source': [1, 3],
         'target': [3, 1]

You cant have the sources and target play double roles ie: node 1 is both a source and a target.

Depending on your use case, you might have to split it up.

For mine, this is about a networking product so I split up my nodes to 'RX' and 'TX' so I don't double up the source/target data list.

Icee
  • 85
  • 9