Nab*_*bla 4 python plotly sankey-diagram
我想绘制一些代表不同物质质量流量的桑基图以供报告。我想用图例来区分这些物质,但我不知道该怎么做。我尝试过showlegend但没有成功
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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3012 次 |
| 最近记录: |