Skip to content

Sankey diagram breaks depending on the order of the trace. #1536

Closed
@adurivault

Description

@adurivault

I'm trying to plot a Sankey diagram, and it breaks. Below is the simplest example with which I managed to reproduce the issue. Might be the same issue as #962, but I'm not using any subplot.

import plotly
import plotly.graph_objs as go

plotly.offline.plot(
    {
        "data": [
            go.Sankey(
                node=dict(
                    label=[1, 2, 3, 4, 5],
                    color=["blue", "blue", "blue", "blue", "blue"],
                ),
                link=dict(
                    source=[3, 3, 5, 3, 4, 1, 2, 1],
                    target=[1, 5, 3, 4, 3, 5, 3, 2],
                    value=[1, 1, 1, 1, 1, 1, 1, 1],
                ),
            )
        ]
    },
    auto_open=True,
)

When changing the order of the links, it works.

import plotly
import plotly.graph_objs as go

plotly.offline.plot(
    {
        "data": [
            go.Sankey(
                node=dict(
                    label=[1, 2, 3, 4, 5],
                    color=["blue", "blue", "blue", "blue", "blue"],
                ),
                link=dict(
                    source=[1, 3, 3, 5, 3, 4, 1, 2],
                    target=[2, 1, 5, 3, 4, 3, 5, 3],
                    value=[1, 1, 1, 1, 1, 1, 1, 1],
                ),
            )
        ]
    },
    auto_open=True,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions