Hope someone has a suggestion! When I dont specify X and Y positions, the Sankey plot looks okay in terms of shape but not in terms of vertical ordering: the vertical/Y order of the elements is not what I want (for every X position the ordering in vertically is different):
When I set pad=100 the Y order is correct for every X position weird enough. But with pad=1, I tried to set X and Y positions explicitly but then the plot looks weird in terms of shape. Dont know why. Any ideas ? See the sample code below:
fig = go.Figure(go.Sankey(
arrangement = "snap",
node = {
"label": ["0br","0cl","0go","0gr","0hy","1br","1cl","1go","1gr","1hy","2br","2cl","2go","2gr","2hy","3br","3cl","3go","3gr","3hy","4br","4cl","4go","4gr","4hy","5br","5cl","5go","5gr","5hy","6br","6cl","6go","6gr","6hy"],
"x": [0, 0, 0, 0, 0, 0.16, 0.16, 0.16, 0.16, 0.16, 0.33, 0.33, 0.33, 0.33, 0.33, 0.5, 0.5, 0.5, 0.5, 0.5, 0.66, 0.66, 0.66, 0.66, 0.66, 0.84, 0.84, 0.84, 0.84, 0.84, 1, 1, 1, 1, 1],
"y": [0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0,0, 0.25, 0.5, 0.75, 1.0],
"color" : ['rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)', 'rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)','rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)', 'rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)', 'rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)', 'rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)', 'rgba(177, 86, 15, 0.85)','rgba(0, 0, 0, 1)','rgba(212,175,55, 0.8)','rgba(0, 153, 51, 0.8)','rgba(212,175,55, 0.8)'],
'pad':1,
"thickness" : 20,
"line" : dict(color = "black", width = 0.5),},
link = {
"source": [0,0,0,0,0,1,1,1,1,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,13,13,13,13,14,15,15,15,16,16,16,17,17,17,18,18,18,18,19,19,20,20,20,21,21,21,22,22,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,28,28,28,28,29],
"target": [5,6,7,8,9,5,6,8,9,7,5,6,7,8,9,5,6,7,8,9,10,11,12,13,14,10,11,13,14,12,10,11,13,14,11,12,13,14,15,16,18,19,15,16,18,19,15,17,19,15,16,18,19,19,20,21,23,20,21,23,20,22,24,20,21,23,24,21,24,25,26,28,25,26,28,27,29,25,26,28,25,27,28,29,30,31,33,34,30,31,33,34,32,30,31,33,34,34],
"value": [322,14,4,6,1,47,1177,36,26,37,8,17,1,209,6,1,4,97,5,333,228,103,5,33,9,110,1016,77,9,139,27,12,203,14,3,5,12,346,336,21,7,1,74,1014,40,6,2,146,1,22,2,286,15,378,377,38,19,4,978,55,2,143,1,1,3,322,7,1,400,362,6,16,9,960,51,139,4,9,9,378,5,1,1,401,377,1,4,3,2,845,127,1,140,11,14,420,1,405]
})) fig.show()
The correct vertical ordering should be br, cl, go, gr, hy for all the horizontal/X values 0...6. So it starts with 0br, 0cl, 0go, 0gr, 0hy and then to the right of it 1br, 1cl, 1go, 1gr, 1hy etc.
KR !