Skip to content

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

@Utorque

Description

@Utorque

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions