I am drawing a a sankey diagram where values go from 1 start node to 5 notes (A, B, C, D and E). I would like the nodes to be plotted in alphabetical order and I thought this could be achieved by my code but this is not the case as you can see from running my code - how can I make sure that A is followed by B, and B followed by C etc.?
I have Python 3.9 and updated plotly to version 4.12.0 but it did not help. I run the code in both Jupyter notebook and in Spyder (4.15) but the order of the nodes is off - can you advice how I can specify the order within the code?
import plotly.graph_objects as go
import plotly.express as px
source = [0, 0, 0, 0, 0]
target = [1, 2, 3, 4, 5]
value = [356, 16, 39, 6, 88]
label = ['Start', 'A', 'B', 'C', 'D', 'E']
color_node = ['#EBBAB5',
'#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD']
color_link = ['#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD',
'#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD','#EBBAB5', '#FEF3C7', '#A6E3D7','#98FB98', '#DDA0DD']
link = dict(source=source, target=target, value = value, color = color_link)
node = dict(label = label, pad=30, thickness=5, color = color_node)
data = go.Sankey(link = link, node = node)
fig = go.Figure(data)
fig.show()