Movable Links to Fixed Links in Sankey

Hi,

When creating a Sankey diagram in R, if I move my target nodes up/down, then the links themselves are moving along with the nodes.
In the image on the top right and the image on the bottom, the nodes have been moved around. However moving the order of the nodes has changed the link position themselves. Is there any way to fix the link position and with that, the colour of the links and nodes themselves? The sankey diagram on the top left is the desired output wanted.


Here's the code I am using:

library(networkD3)
library(tidyverse)
nodes = data.frame("name" = c("B1","B2","B3","B4","B5","B6"))
links = as.data.frame(matrix(c(
  0,1,20,
  0,2,25,
  0,3,15,
  0,4,40,
  0,5,30),
  byrow = T,ncol = 3  ))
names(links) = c("source","target","value")
sankeyNetwork(Links = links, Nodes = nodes,
              Source = "source", Target = "target",
              Value = "value", NodeID = "name",
              fontSize= 12, nodeWidth = 30)

Any help would be appreciated.

Thank you!

1 Like

Not sure I follow what you mean by this.
Do you mean when you click and drag the plot? or when you make changes to the table?
Can you give an example?

Hi, this is happening when I click and drag the nodes on the plot. I have actually edited my post,hope it helps understanding it better.

not with networkD3, not "out of the box". networkD3's primary purpose for existence is to automatically make "ideal" layouts, so trying to manually adjust to something else is somewhat going against the grain.

Is there a way to assign numbers to the arrows?

There are no arrows in the sankey plots. Maybe it would be best to open a new topic with a reproducible example.

I think his example is nice. Question: how can one assign the "25" as a value to B2 so that is shows up?