R: visnetwork horizontal movement for visHierarchical

255 Views Asked by At

When using visnetwork and the visHierarchical layout, I've noticed that one can only move the nodes either horizontally or vertically, but not in both directions. This is troublesome when you have nodes in the same level connecting to each other. Is there a way to enable both horizontal and vertical movement of the nodes in a hierarchical layout? Otherwise, one has to manually set up all of the x and y coordinates to get a decent looking plot. Here is an example where you can see it can only be moved in one direction:

library(visnetwork)    
nodes <- data.frame(id = 1:7)
edges <- data.frame(from = c(1,2,2,2,3,3),
 to = c(2,3,4,5,6,7))

visNetwork(nodes, edges, width = "100%") %>% 
  visEdges(arrows = "from") %>% 
  visHierarchicalLayout() # same as   visLayout(hierarchical = TRUE) 

The direction of the allowed movement seems dictated by the the direction option with the visHierarchicalLayout call.

0

There are 0 best solutions below