1import plotly.graph_objects as go
2
3fig = go.Figure(data=[go.Sankey(
4 node = dict(
5 pad = 15,
6 thickness = 20,
7 line = dict(color = "black", width = 0.5),
8 label = ["A1", "A2", "B1", "B2", "C1", "C2"],
9 color = "blue"
10 ),
11 link = dict(
12 source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A2, B1, ...
13 target = [2, 3, 3, 4, 4, 5],
14 value = [8, 4, 2, 8, 4, 2]
15 ))])
16
17fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
18fig.show()
19