plotly.graph_objects.sankey.node.Line does not work with an array of color
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 18.8k
- Fork
- 2.8k
- Merge medio
- 16h 26m
- PR unite (30g)
- 21
Descrizione
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 :

Thanks,
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo l’esempio go.Sankey fornito e confronta il comportamento documentato dell’array con le linee dei nodi renderizzate. Traccia il modo in cui node.line.color viene gestito quando viene passato attraverso il costruttore Sankey, quindi verifica che i quattro colori previsti vengano renderizzati sui nodi corrispondenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100