Thanks for the fast response and welcome Jon!
That actually might be part of the problem, I’m not sure what data I need to get the desired result.
code:
init_notebook_mode(connected=True)
data_trace = dict(
type='sankey',
domain = dict(
x = [0,1],
y = [0,1]
),
orientation = "h",
valueformat = ".0f",
node = dict(
pad = 10,
thickness = 0,
line = dict(
color = "black",
width = 0
),
label = scottish_df['Node, Label'].dropna(axis=0, how='any'),
color = scottish_df['Color']
),
link = dict(
source = scottish_df['Source'].dropna(axis=0, how='any'),
target = scottish_df['Target'].dropna(axis=0, how='any'),
value = scottish_df['Value'].dropna(axis=0, how='any'),
color = scottish_df['Link Color'].dropna(axis=0, how='any'),
)
)
layout = dict(
title = "Scottish Referendum Voters who now want Independence",
height = 900,
font = dict(
size = 10
),
)
fig = dict(data=[data_trace], layout=layout)
iplot(fig, validate=False)
The data is (same as the link):
|Source|Target|Value|Color|Node, Label|Link Color|
|1|0|5|20|#F27420|Remain+No – 28|rgba(253, 227, 212, 0.5)|
|2|0|6|3|#4994CE|Leave+No – 16|rgba(242, 116, 32, 1)|
|3|0|7|50|#FABC13|Remain+Yes – 21|rgba(253, 227, 212, 0.5)|
|4|1|5|14|#7FC241|Leave+Yes – 14|rgba(219, 233, 246, 0.5)|
|5|1|6|50|#D3D3D3|Didn’t vote in at least one referendum – 21|rgba(73, 148, 206, 1)|
Ideal outcome:
My outcome:
I think what I’m confused about is, assuming it doesn’t look right due to missing data, how are the labels associated with the right target/source? e.g. the Target is undefined, but how do I define it.