In [1]:
# 桑基图可视化数据流,非常适合能源、材料和财务数据。
# 以 Matthew Henry Phineas Riall Sankey 命名,它显示了系统各阶段或部分之间的流量。
# 节点宽度与流量数量成比例,易于理解数据规模和方向。
In [2]:
import plotly.graph_objects as go
labels = ["Coal", "Solar", "Wind", "Nuclear", "Residential", "Industrial", "Commercial"]
source = [0, 1, 2, 3, 0, 1, 2, 3]
target = [4, 4, 4, 4, 5, 5, 5, 5]
value = [25, 10, 40, 20, 30, 15, 25, 35]
# Create the Sankey diagram object
fig = go.Figure(data=[go.Sankey(
node=dict(
pad=15,
thickness=20,
line=dict(color="black", width=0.5),
label=labels
),
link=dict(
source=source,
target=target,
value=value
))])
fig.update_layout(title_text="Energy Flow in Model City", font_size=12)
fig.show()
In [ ]: