plotly / plotly/plotly.py

go.Sankey not respecting (x,y) coordinates

未关闭
#2,902 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

The code below

import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go
from dash import Dash

app = Dash(__name__)


def sankey():
    x = [0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0]
    y = [
        0.21630069,
        0.47642676,
        0.54677235,
        0.62167333,
        0.74199201,
        0.29388136,
        0.73906564,
        0.89679547,
        0.95161119,
        0.29388135,
    ]
    label = list("ABCDEFGHIJ")

    source = [0, 1, 0, 1, 2, 2, 2, 2, 0, 1, 2, 2, 3, 4, 5, 6, 6, 8]
    target = [5, 5, 2, 2, 5, 5, 7, 7, 6, 6, 6, 6, 5, 5, 9, 9, 8, 9]
    value = [
        4.03086075e-02,
        3.13536457e-01,
        4.74989358e-03,
        4.82905398e-02,
        2.57156646e-03,
        2.55178406e-02,
        1.15108889e-03,
        1.17027262e-02,
        7.78313638e-03,
        7.07743914e-02,
        1.02723822e-03,
        1.10699730e-02,
        1.43875830e-01,
        6.19524093e-02,
        3.81934471e-01,
        2.05828238e-01,
        6.19685055e-02,
        2.53269630e-17,
    ]

    fig = go.Figure(
        data=[
            go.Sankey(
                arrangement="fixed",
                node=dict(
                    # thickness=20,
                    # line=dict(color="black", width=0.5),
                    label=label,
                    x=x,
                    y=y,
                ),
                link=dict(source=source, target=target, value=value),
            )
        ]
    )
    return fig


app.layout = html.Div([dcc.Graph(figure=sankey())])

if __name__ == "__main__":
    app.run_server(debug=True)

generates
newplot (20)
which is not expected as:

  • nodes A,B,C,D and E have all same x coordinates (should be aligned on same vertical line)
  • nodes A,B,C,D,E should be ordered from top to bottom as they have increasing y coordinates

I may have misunderstood the (x,y) coordinates logic or it is a bug...

Libraries version:
plotly==4.9.0
dash==1.16.3
dash-core-components==1.12.1
dash-html-components==1.1.1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用列出的 plotly、Dash 和组件版本运行提供的 Sankey 示例,然后检查 arrangement="fixed" 如何应用所提供的节点 x 和 y 值。完成标准是节点 A–E 垂直对齐,并按 y 值递增的顺序从上到下显示,同时为所报告的行为提供覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。