1

I created a Sankey diagram using the plotly package.

Please look at below example. I tried to make five streams, 1_6_7, 2_6_7, and so on. But two of five links between 6 and 7 disappeared. As far as I see, plotly allows to make only three or less links between two nodes.

Can I remove this restrictions ? Any help would be greatly appreciated.

Here is an example code and the outputs:

d <- expand.grid(1:5, 6, 7)
node_label <- 1:max(d)
node_colour <- scales::alpha(RColorBrewer::brewer.pal(7, "Set2"), 0.8)
link_source_nodeind <- c(d[,1], d[,2]) - 1
link_target_nodeind <- c(d[,2], d[,3]) - 1
link_value <- rep(100, nrow(d) * 2)
link_label <- rep(paste(d[,1], d[,2], d[,3], sep = "_"),  2)
link_colour <- rep(scales::alpha(RColorBrewer::brewer.pal(5, "Set2"), 0.2), 2)

p <- plotly::plot_ly(type = "sankey", 
                     domain = c(x =  c(0,1), y =  c(0,1)), 
                     orientation = "h",
                     node = list(label = node_label,
                                 color = node_colour),
                     link = list(source =  link_source_nodeind,
                                 target = link_target_nodeind,
                                 value =  link_value,
                                 label =  link_label,
                                 color = link_colour))
p

enter image description here

cuttlefish44
  • 6,586
  • 2
  • 17
  • 34
  • Are you interested only in `plotly` solution or other R packages would also work? – pogibas Mar 04 '18 at 08:19
  • @PoGibas; I'm interested in not only `plotly` but also other R packages giving an interactive sankey-diagram (hover text is necessary). – cuttlefish44 Mar 04 '18 at 12:00

0 Answers0