plotly / plotly/plotly.py

node positions do not work with link value zero in Sankey

Open
#2,152 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python Sankey examples and comparing freeform positioning when one link has value zero. Trace the Sankey rendering path from the Python figure definition to the component that handles node positions. Done means manual coordinates remain effective for nodes with no links or only zero-valued links, with a regression test covering both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.