plotly.graph_objects.sankey.node.Line does not work with an array of color
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 18.8k
- Forks
- 2.8k
- Merge moyen
- 16 h 26 min
- PR mergées (30 j)
- 21
Description
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,
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par exécuter l’exemple go.Sankey fourni et comparez le comportement documenté du tableau avec les lignes de nœud rendues. Suivez la manière dont node.line.color est traité lorsqu’il est transmis au constructeur Sankey, puis vérifiez que les quatre couleurs attendues sont rendues sur les nœuds correspondants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100