Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Sankey diagram: position of node cannot be rendered correctly

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r

Research direction

Start with the reproducible R code in the issue and run it using Plotly 4.10.3 to confirm how Sankey arrangement="snap" handles the supplied x and y positions. Investigate the Sankey rendering behavior for nodes 13–16, then verify that nodes 13, 14, 15, and 16 remain in the same column at x=0.999.

Written by the indexing model from the issue text.

Description

Hello people!
I am trying to make a sankey diagram with Plotly, however, the alignment of certain node cannot be rendered correctly as I set.
PS: my Plotly version is 4.10.3 and R version is 4.3.1

Here is my code:

library("plotly")

# My data base
values <- c(10,1811,530,363,271,601,681,37,46,18,109,39,3,22,74,22,10,
            14,3,81,0,1,19,1807,521,363,270,601,16,36,8,46,86,1,0,0,23,
            14,18,34,684,23,0,16,0,23,0,0,0,23,14,18,69,1,34,0,0,0,684,
            43,643,101,6,68,43,620,101,6,19,1807,521,363,270,601,16,36,
            8,46,15,1555,79,244,346,4,115,2,2,0,4,17,251,265,1,3,25,3,
            16,0,8,43,105,24,2,1,1,6,0,601,0,129,196,109,14,82,124,1,
            34,2,0,13,0,11)
target <- c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,
            4,4,5,5,5,5,5,5,5,5,5,5,5,10,10,10,10,10,10,10,10,11,11,11,
            11,11,11,11,11,6,6,6,6,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,13,13,13,
            13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,15,15,
            15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,9,9,9,9)
source <- c(0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,2,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,
            11,11,11,6,6,6,6,6,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,
            8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8)

num_node <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
x_position <- c(0.05,0.05,0.2,0.35,0.35,0.35,0.65,0.8,0.8,0.9,0.45,0.45,0.45,0.999,0.999,0.999,0.999)
y_position <- c(0.45,0.6,0.55,0.15,0.45,0.6,0.75,0.85,0.55,0.99,0.6,0.6,0.6,0.3,0.3,0.3,0.3)

# Sankey diagram with Plotly
fig <- plot_ly(
  type = "sankey",
  arrangement = "snap",
  node = list(
    label = num_node,
    x = x_position,
    y = y_position,
    pad = 15,
    thickness = 15
  ),
  link = list(
    source = source,
    target = target,
    value =  values
  )
)

fig

What I would expect is that node 13, 14, 15, 16 be at the same colomn, as I set their x position to 0.999. See picture below:
Capture d’écran 2024-01-11 à 18 38 34

However, for some reason, my node 13 would like to be in the middle of my diagram instead of the position where it should have been. See picture below:
Capture d’écran 2024-01-11 à 18 41 16

Does anyone have some insights why the node cannot accept x and y position I set? Thank you guys very much!

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from plotly/plotly.R

All issues in plotly/plotly.R

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.