plotly.graph_objects.sankey.node.Line does not work with an array of color
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 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,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided go.Sankey example and compare the documented array behavior with the rendered node lines. Trace how node.line.color is handled when passed through the Sankey constructor, then verify that the four expected colors render on the corresponding nodes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100