Skip to content

Sankey Paths can be plotted outside the plot area #1758

Open
@wdm0336

Description

@wdm0336

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions