You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Plotly绘制Sankey图时出现arrowlen参数无效报错

Plotly Sankey图arrowlen属性报错原因

报错信息

ValueError: Invalid property specified for object of type plotly.graph_objs.sankey.Link: 'arrowlen'

使用环境

  • Plotly版本:5.15.0
  • 安装命令:
!pip install plotly==5.15.0
!pip install "notebook>=5.3" "ipywidgets>=7.5"

复现代码

import plotly.graph_objects as go
fig = go.Figure(go.Sankey(
    arrangement='snap',
    node=dict(
        label=['A', 'B', 'C', 'D', 'E', 'F'],
        x=[0.2, 0.1, 0.5, 0.7, 0.3, 0.5],
        y=[0.7, 0.5, 0.2, 0.4, 0.2, 0.3],
        pad=10  
    ),
    link=dict(
        arrowlen=15,
        source=[0, 0, 1, 2, 5, 4, 3, 5],
        target=[5, 3, 4, 3, 0, 2, 2, 3],
        value=[1, 2, 1, 1, 1, 1, 1, 2],
        
    )
))

fig.show()

原因分析

  • arrowlen是Plotly 5.16.0及更高版本才新增的Sankey链接配置属性,你当前使用的5.15.0版本不支持该参数,因此触发属性不存在的报错。
  • 官网示例文档基于最新版Plotly编写,和你本地安装的版本存在兼容性差异。

内容的提问来源于stack exchange,提问作者user1357015

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 12:07:25