4

Where does Plotly store the X and Y coordinates of nodes (or the Plotly equivalent of XY coordinates)? Specifically when type = "sankey".

For instance:

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
      )
    ),
    link = list(
      source = c(0,1,0,2,3,3),
      target = c(2,3,3,4,4,5),
      value =  c(8,4,2,8,4,2)
    )
  )

fig <- fig %>% layout(
    title = "Basic Sankey Diagram",
    font = list(
      size = 10
    )
)
fig

enter image description here

How could I find the X and Y coordinates that Plotly has assigned to A1, A2, B1, B2, C1, and C2? What I'd like to do is extract the node names along with their coordinates to a new data frame.

Obed
  • 403
  • 3
  • 12
  • You can set the x and y coordinates for the nodes. Take a look at **Define Node Position** on this page - https://plotly.com/python/sankey-diagram. – viggnah Aug 09 '22 at 07:17

0 Answers0