Skip to content

node positions do not work with link value zero in Sankey  #2152

Open
@rubenbfeld

Description

@rubenbfeld

Hello,
I'm new to the plot.ly lib but I already discovered an issue.
If there is a node with:

  • no links
  • only links with the value of zero

the manual positioning doesn't work anymore except if you delete the relating coordinates of this node and keep the node in the list (see third example).

Below you can find a short testing code with the generated output.

working example

import plotly.graph_objects as go
data=go.Sankey(
    arrangement = "freeform",
    node = {
        "label": ["A", "B", "C", "D", "E", "F"],
        "x": [0.2, 0.1, 0.9, 0.7, 0.3, 0.9],
        "y": [0.1, 0.9, 0.2, 0.1, 0.9, 0.9],
        'pad':100},  # 10 Pixels 
    link = {
        "source": [0, 0, 1, 4, 4, 3, 3],
        "target": [1, 3, 4, 3, 5, 2, 5],
        "value": [3, 3, 5, 4, 10, 1, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

newplot(6)

node with only one link with value of zero

import plotly.graph_objects as go
data=go.Sankey(
    arrangement = "freeform",
    node = {
        "label": ["A", "B", "C", "D", "E", "F"],
        "x": [0.2, 0.1, 0.9, 0.7, 0.3, 0.9],
        "y": [0.1, 0.9, 0.2, 0.1, 0.9, 0.9],
        'pad':100},  # 10 Pixels 
    link = {
        "source": [0, 0, 1, 4, 4, 3, 3],
        "target": [1, 3, 4, 3, 5, 2, 5],
        "value": [3, 3, 5, 4, 10, 0, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

newplot(7)

kind of working again cause coordinates of C are deleted

import plotly.graph_objects as go
data=go.Sankey(
    arrangement = "freeform",
    node = {
        "label": ["A", "B", "C", "D", "E", "F"],
        "x": [0.2, 0.1, 0.7, 0.3, 0.9],
        "y": [0.1, 0.9, 0.1, 0.9, 0.9],
        'pad':100},  # 10 Pixels 
    link = {
        "source": [0, 0, 1, 4, 4, 3, 3],
        "target": [1, 3, 4, 3, 5, 2, 5],
        "value": [3, 3, 5, 4, 10, 0, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

newplot(12)

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