下面的有向示例图最初是用visIgraphLayout("layout_with_sugiyama")
算法排列的:
library(dplyr)
library(visNetwork)
### create nodes
nodes <- tibble(id = c (1:13), group = c("D","D","D","A","C","C","C","C","A","A","C","A","A"),
label = c("only outgoing a","only outgoing b","only outgoing c","only incoming d","e","f","g","h","only incoming i","only incoming j","k","only incoming l","only incoming m")
### create edges
edges <- tibble(id = 1:12, from = c(1,1,2,3,3,7,6,8,8,5,11,11), to = c(5,6,5,4,7,8,8,9,11,10,12,13), arrows = "to")
### visualize graph
visNetwork(nodes, edges, main = "Test") %>%
visGroups(groupname = "A", size = 25, color = list(
background = "#005A83",
border = "#005A83")) %>%
visGroups(groupname = "C",size = 20, color = list(
background = "#994350",
border = "#000000")) %>%
visGroups(groupname = "D", size = 20, color = list(
background = "#44706F",
border = "#44706F")) %>%
visEdges(smooth = F, font = list("size"=5), color = "black") %>%
visLegend(width = 0.2) %>%
visIgraphLayout("layout_with_sugiyama") %>%
visInteraction(navigationButtons = TRUE) %>%
visPhysics(enabled = F)
该算法将有向图从上到下排列。我想从左到右可视化它。因此,我只想将图形向左旋转 90 度,以便绿色的起始节点在左侧,蓝色的结束节点在右侧。图例等不应受到影响。
有人有想法吗?