I have a sankey plot using plotly but I do not managed to display values on links (only on the hover toolbox). In In R, how to display value on the links/paths of Sankey Graph? they add custom code to do so in R but I was not able to reproduce it in python. Any help welcomed :)
Lets say I have this code:
import plotly.graph_objects as go
fig = go.Figure(data=[go.Sankey(
node = dict(
pad = 15,
thickness = 20,
line = dict(color = "black", width = 0.5),
label = ["A1", "A2", "B1", "B2", "C1", "C2"],
color = "blue"
),
link = dict(
source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A1, B1, ...
target = [2, 3, 3, 4, 4, 5],
value = [8, 4, 2, 8, 4, 2]
))])
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()
I expected to be able to do this like for sunburst:
fig.update_traces(textinfo="label+value", selector=dict(type='sunburst'))