plotly / plotly/plotly.py

Sankey Plot Node Positions are incorrect

Open
#4,714 0 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

Describe your context

  • replace the result of pip list | grep dash below
dash                 1.5.1              
dash-core-components 1.4.0              
dash-html-components 1.0.1              
dash-renderer        1.2.0              
dash-table           4.5.0  

Describe the bug

Want to position Nodes along X-Axis in a Sankey Plot and Y to be automatically Adjusted. When I define X Positions only Sankey doesn't align the Nodes. But If I define Y Positions then only Sankey aligns the Nodes.

    def create_sankey_plot(self, source_r, target_r, value_r, colors_r,
                           labels_r, labels_a, colors_a):
        return go.Sankey(
            node=dict(
                pad=15,
                thickness=20,
                line=dict(color="black", width=0.5),
                label=labels_a,
                color=colors_a,
                x=[0.2, 0.1, 0.5, 0.7, 0.3, 0.5]
            ),
            link=dict(
                source=source_r,
                target=target_r,
                value=value_r,
                color=colors_r,
                line={'width': 1},
                label=labels_r
            )
        )

Above code will not align Nodes. Below code works:

def create_sankey_plot(self, source_r, target_r, value_r, colors_r,
                           labels_r, labels_a, colors_a):
        return go.Sankey(
            node=dict(
                pad=15,
                thickness=20,
                line=dict(color="black", width=0.5),
                label=labels_a,
                color=colors_a,
                x=[0.2, 0.1, 0.5, 0.7, 0.3, 0.5],
                y=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
            ),
            link=dict(
                source=source_r,
                target=target_r,
                value=value_r,
                color=colors_r,
                line={'width': 1},
                label=labels_r
            )
        )

Expected behavior

Align Nodes if provided only X values / Y values making other default.

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 reproducing the reported go.Sankey case with only node.x values, then compare it with the example that also supplies node.y values. Investigate the Sankey node-position handling exposed by the Python API and verify that supplying only one coordinate still aligns nodes while the other is automatically adjusted.

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.