plotly / plotly/plotly.py

plotly.graph_objects.sankey.node.Line does not work with an array of color

未關閉
#4,155 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug P3
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

Hi everyone,
The docs says that the argument color either takes a color or an array of colors. However, when I pass an array of colors, it always shows up black instead of the specified color. Here is a code example that does the bug :

import plotly.graph_objects as go

# define the node labels and colors
node_labels = ["A", "B", "C", "D"]
node_colors = ["red", "blue", "green", "purple"]

#Array of colors for the node's line
node_line_colors = ["black", "gray", "orange", "yellow"]

# define the links between the nodes
link_source = [0, 0, 1, 1, 2, 2]
link_target = [1, 2, 2, 3, 0, 3]
link_value = [8, 4, 2, 6, 10, 12]

# create the Sankey diagram
fig = go.Figure(data=[go.Sankey(
    node=dict(
        label=node_labels,
        color=node_colors,
        line=dict(
            color=node_line_colors, # Colors I want to have for my diagram
            width=10 # Bigger to properly see that the colors aren't here
        )
    ),
    link=dict(
        source=link_source,
        target=link_target,
        value=link_value
    )
)])

fig.show()

I also tried to manually add the colors like this instead of using the constructor :
fig.data[0]['node']['line']['color'] = node_line_colors

But the node's lines still show up black instead of coloried.
Expected result :
black line for A node,
gray line for B node,
green line for C node,
purple line for D node ;

Actual result :
image

Thanks,

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先執行提供的 go.Sankey 範例,並比較文件所述的陣列行為與算繪出的節點線。追蹤 node.line.color 傳遞給 Sankey 建構函式時的處理方式,然後驗證預期的四種色彩是否算繪在相應的節點上。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
data-visualization
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。