I want to plot some sankey diagrams representing mass flows of different substances for a report. I want to put a legend to differentiate the substances but I don't know how to do it. I've tried showlegend
without success
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 = ['household','industry','waste'],
color = "blue"
),
link = dict(
source = [0,1,0,1], # indices correspond to labels, eg A1, A2, A2, B1, ...
target = [2,2,2,2],
value = [7190,2074,4483,74.50],
label = ['aluminium','aluminium','copper','copper'],
color = ['#d7d6d6','#d7d6d6','#f3cf07','#f3cf07']
))])
fig.update_layout(showlegend=True)
fig.show()