我正在尝试绘制一个类似于流程图的网络可视化。我与以下代码相当接近,但我有几个问题:
- 这是最好的 layout() 算法,还是我可以手动为每个节点分配一个位置>
- 我怎样才能确保这些节点不会在图中重叠(就像他们在这里所做的那样)?
- 我可以将一个节点指定为“锚点”或起点吗?即,我可以使“C”成为最顶部或最左侧的节点吗?
非常感谢!!
library("igraph")
L3 <- LETTERS[1:8]
d <- data.frame(start = sample(L3, 16, replace = T), end = sample(L3, 16, replace = T),
weight = c(20,40,20,30,50,60,20,30,20,40,20,30,50,60,20,30))
g <- graph.data.frame(d, directed = T)
V(g)$name
E(g)$weight
ideg <- degree(g, mode = "in", loops = F)
col=rainbow(12) # For edge colors
plot.igraph(g,
vertex.label = V(g)$name, vertex.label.color = "gray20",
vertex.size = ideg*25 + 40, vertex.size2 = 30,
vertex.color = "gray90", vertex.frame.color = "gray20",
vertex.shape = "rectangle",
edge.arrow.size=0.5, edge.color=col, edge.width = E(g)$weight / 10,
edge.curved = T,
layout = layout.reingold.tilford)