-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Hi guys:
I have tried the node position for plotly sankey diagram. Seems like there is still some bugs with it. What I am trying to do is to connect network communities between different years. For example, "2007_1" is a network community in year 2007. If there is a link between "2007_1" and "2008_2", it means that there should be a weighted band connecting them in the diagram. But as I feed the data in the program, the positions for some nodes are messed up. Does anyone know how to fix it?
I have posted the code and the data down below:
import pandas as pd
import plotly.graph_objects as go
fig = go.Figure(
go.Sankey(
arrangement="snap",
node = {
#line = dict(color = "black", width = 0.5),
"label" : ['2005_1', '2006_1', '2006_4', '2007_3', '2006_5', '2007_2', '2006_6', '2007_4', '2007_1', '2008_2', '2007_5', '2008_9', '2007_6', '2008_4', '2007_7', '2008_3', '2008_6', '2007_8', '2008_1', '2007_9', '2008_5'], # label list
"x" : [0.1, 0.2, 0.2, 0.3, 0.2, 0.3, 0.2, 0.3, 0.3, 0.4, 0.3, 0.4, 0.3, 0.4, 0.3, 0.4, 0.3, 0.4, 0.3, 0.4, 0.3, 0.4], # x axis for each label
"y" : [0.1, 0.1, 0.2, 0.1, 0.3, 0.2, 0.4, 0.3, 0.4, 0.1, 0.5, 0.2, 0.6, 0.3, 0.7, 0.4, 0.7, 0.5, 0.8, 0.6, 0.9, 0.7], # y axis for each label
'pad' : 10,
},
link = {
"source" : [0, 2, 4, 6, 8, 10, 12, 14, 14, 17, 19], # indices correspond to labels, eg A1, A2, A2, B1, ...
"target" : [1, 3, 5, 7, 9, 11, 13, 15, 16, 18, 20], # indices correspond to labels, eg A1, A2, A2, B1, ...
"value" : [0.4, 0.6, 0.8, 0.7, 0.5, 0.4, 0.8, 1.5, 1.2, 2.8, 0.9] # link weight between two labels
}
)
)
#fig.update_layout(dict1=dict(height=600, width=900))#, title_text="Basic Sankey Diagram", font_size=10)
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()
Metadata
Metadata
Assignees
Labels
No labels