plotly / plotly/plotly.js

Explicit node coordinates (x/y positions) not fully respected in Sankey diagram

Open
#7,758 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue P3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

We (@janosh) are trying to generate a Sankey diagram but for some reason the explicit coordinates are not fully respected. The "right_a" node has a coordinate of (0.9, 0.05) (top right), but for some reason shows at bottom left.

plotly 6.3.1, macos 26.0.1

import plotly.graph_objects as go


labels = ["left_a", "left_b", "left_c", "left_d", "left_e", "left_f", "left_g", "left_h", "left_i", "left_j", "left_k", "left_l", "left_m",
    "left_n", "left_o", "left_p", "left_q", "left_r",
    "right_a", "right_b", "right_c", "right_d", "right_e", "right_f", "right_g", "right_h", "right_i", "right_j", "right_k", "right_l"]

node_pos = {
    "left_a": (0.1, 0.1), "left_b": (0.1, 0.14), "left_c": (0.1, 0.18), "left_d": (0.1, 0.23),
    "left_e": (0.1, 0.27), "left_f": (0.1, 0.31), "left_g": (0.1, 0.35),
    "left_h": (0.1, 0.40), "left_i": (0.1, 0.44), "left_j": (0.1, 0.48),
    "left_k": (0.1, 0.52), "left_l": (0.1, 0.56), "left_m": (0.1, 0.61),
    "left_n": (0.1, 0.65), "left_o": (0.1, 0.69), "left_p": (0.1, 0.73),
    "left_q": (0.1, 0.77), "left_r": (0.1, 0.82),
    "right_a": (0.9, 0.05),
    "right_b": (0.9, 0.15), "right_c": (0.9, 0.25), "right_d": (0.9, 0.35), "right_e": (0.9, 0.45), "right_f": (0.9, 0.55), "right_g": (0.9, 0.65),
    "right_h": (0.9, 0.75), "right_i": (0.9, 0.85), "right_j": (0.9, 0.93), "right_k": (0.9, 0.97), "right_l": (0.9, 0.99)}

sources = [0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10,
    10, 10, 11, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 18, 18, 18, 19, 19, 19, 19, ]

targets = [23, 21, 20, 26, 30, 20, 24, 22, 21, 20, 20, 25, 29, 22, 22, 29, 20, 20, 22, 25, 24, 29, 20, 22, 29, 21, 21, 20, 24, 30, 22,
    20, 20, 21, 25, 22, 30, 28, 24, 29, 20, 21, 24, 20, 20, 22, 20, 23, 21, 24, 31, 25, 21, 22, 20, 23, 30, 27, 26, 24, 21, 20, 22,
    23, 30, 25, 20, 21, 22, 20, 21, 25, 20, 22, 21, 24, ]
values = [1 for _ in targets]
assert len(sources) == len(targets) == len(values)

x_positions: list[float] = [node_pos[lbl][0] for lbl in labels]
y_positions: list[float] = [node_pos[lbl][1] for lbl in labels]

fig = go.Figure(
    go.Sankey(
        arrangement="fixed",
        node=dict(
            label=labels,
            x=x_positions,
            y=y_positions,
        ),
        link=dict(
            source=sources,
            target=targets,
            value=values,
        ),
    )
)

# fig.show()

fig.write_image("debug.svg", format="svg")

Image

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 provided Sankey reproduction with arrangement="fixed" and exporting debug.svg, then trace the Sankey implementation and its handling of node x/y coordinates. Done means explicit coordinates such as right_a at (0.9, 0.05) are reflected in the rendered diagram without regressing other fixed-position nodes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.