i am trying to order the flows of my sankey diagram by color. The color is red for not implemented, yellow for recommended and green for implemented. These colors go through the diagram. Now i would like to have all green (implemented) flows go into and out of a node at the top then yellow and then red.
See the urges node for example. (third column at the top) My Sankey
I tried sorting the data itself, but it didn't to the trick 100%. Any ideas? :)
Thx!
I am using Plotly Version 5.14.1
Here is my code:
fig = go.Figure(data=[go.Sankey(
node = dict(
pad = 15,
thickness = 20,
line = dict(color = "black", width = 0.5),
label = [
"Awareness",
"Best Practice",
"Implementation ",
"Resources",
"Training ",
"Campaigns",
'Training',
'Research',
'National Strategy',
'Services',
'Children',
'Due Diligence',
'Legal Framework',
'Services',
'NGOs',
'Services',
'strongly encourages',
'not recommended',
'urges',
'encourages',
'invites',
'not implemented',
'implemented',
'recommended'],
color = "gray"
),
link = dict(
source = [1, 2, 2, 3, 2, 3, 0, 2, 1, 2, 0, 1, 8, 11, 13, 10, 13, 14, 15, 5, 4, 13, 5, 7, 12, 5, 5, 13, 9, 13, 16, 18, 16, 16, 17, 18, 19, 20],
target = [8, 11, 10, 14, 13, 15, 4, 13, 7, 12, 5, 9, 16, 16, 16, 18, 18, 18, 16, 16, 16, 16, 17, 17, 17, 18, 19, 19, 20, 20, 22, 22, 23, 21, 21, 21, 21 ,21],
value = [1, 1, 1, 1, 2, 1, 2, 6, 1, 1, 4, 1, 1, 1, 1,1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 6, 3, 1, 3, 2],
color = ['green', 'green', 'green', 'green', 'green', 'yellow', 'red', 'red', 'red', 'red', 'red', 'red', 'green', 'green', 'green', 'green', 'green', 'green', 'yellow', 'red', 'red', 'red', 'red', 'red', 'red', 'red', 'red', 'red', 'red', 'red', 'green', 'green', 'yellow', 'red', 'red', 'red', 'red', 'red']
))])
fig.update_layout(title_text="Sankey Diagram Albanien", font_size=10)
fig.show()