plotly / plotly/plotly.R

Sankey Paths can be plotted outside the plot area

Open
#1,758 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When a link is plotted from a source node to the right of a target node on the diagram (the path loops around and goes upstream), then the path can be plotted outside the plot area. I have data that does this to such an extent that the hover information is not showing.

library(plotly)

fig <- plot_ly(
  type = "sankey",
  orientation = "h",
  
  node = list(
    label = c("A1", "A2", "B1", "B2", "C1", "C2"),
    color = c("blue", "blue", "blue", "blue", "blue", "blue"),
    pad = 15,
    thickness = 20,
    line = list(
      color = "black",
      width = 0.5
    )
  ),
  
# With your example, I added the 7th values in each of the vectors in the link list.
  link = list(
    source = c(0,1,0,2,3,3,4),
    target = c(2,3,3,4,4,5,3),
    value =  c(8,4,2,8,4,2,40)
  )
)
fig <- fig %>% layout(
  title = "Basic Sankey Diagram",
  font = list(
    size = 10
  )
)

fig

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

Run the provided R example with the Sankey link from a right-side source to an upstream target, then inspect the Sankey rendering entry point responsible for path placement. Done means the looped path remains within the plot area and its hover information is visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
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.