Interpreting error in Sankey

I’m revisiting an old plotly script to create a Sankey diagram. However, when I try to run it, I get the error:

Error in proposed[["hoveron"]] : subscript out of bounds

Can anyone shed some light on this? I’ve gone back to the example script where I created my plot from and I still receive the same error.

My code is:

p <- plot_ly(
  type = "sankey",
  domain = c(
    x = c(0, 1),
    y = c(0, 1)
  ),
  orientation = "h",
  
  node = list(
    label = c("P01","P02","P03","P05","P06","P07","P08","P09","P10","P12","P13","P14","P16","P17","P19","P21","P22",
              "P23","P24","P25","P26","R01","R02","R03","R04","R05","S01","S02","S03","S04","S05","S06","S07","S08",
              "S11","S14","S16","S17","S24","S25"),
    color = c("#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB86","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860","#377EB860", "#377EB860","#377EB860","#377EB860","#377EB860"),
    pad = 5,
    thickness = 10,
    line = list(
      color = "black",
      width = 0.5
    )
  ),
  
  link = list(
    source = c(4,8,11,14,14,18,19,19,20,20,27,27,27,27,27,34,3,4,11,14,27,27,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,9,9,12,13,13,16,16,16,16,17,28,30,30,30,31,32,0,0,0,0,0,0,0,0,0,0,0,0,1,6,6,6,6,26,26,32),
    target = c(7,33,22,22,27,7,21,22,7,13,22,23,24,26,33,26,32,13,32,26,17,32,22,3,4,8,10,11,14,15,17,18,22,24,27,29,34,35,37,38,39,3,4,10,8,33,21,21,22,19,21,22,26,22,21,21,22,25,22,21,1,2,5,9,13,16,21,26,28,30,32,36,21,0,1,9,31,21,22,22),
    value = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
  )
) %>%
  layout(
    title = "Basic Sankey Diagram",
    font = list(
      size = 10
    )
  )
1 Like

I have the same problem since this afternoon, did you resolved it ?

Not with the latest version of plotly. I worked around by going back to the previous version of plotly and then it would run.

Not a final fix but good enough for now!

1 Like

Ok, I’m back to the 4.7.1 version and it works again. Thank you !

same error message here too, and it still didn’t work when i re-installed 4.7.1 (on mac).

Also I had to amend the code given in the example, and change all the

json_data$data[[1]]$link$source

type links to:

json_data$data$link$source[[1]]

could someone update the page and fix the code…?

The code runs for me using the previous plotly version so I’ll leave it as is for now but maybe your modification will help someone else.