我想绘制一个网络可视化,以类似于流程图。我相当接近用下面的代码,但我有几个问题:如何使用固定位置控制igraph绘图布局?
- 这是最好的布局()算法,或我可以手动分配>
- 我怎样才能使每个节点的位置确定这些节点在剧情中不重叠(就像他们在这里做的那样)?
- 我可以将一个节点分配为“锚点”还是起点?即,我可以让“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)
感谢您的提示!像这样把位置放在一起:l2 < - as.matrix(data.frame(c(0,6,12,12,12,24,24,24),c(0,.5,.5 ,0,-1,1,-1,。25))) – 2011-03-20 04:51:13
2年后,这个答案对我有帮助:-) – 2013-06-30 14:26:00
Sacha,当我应用你的代码时,我得到ncol(x)中的错误:找不到对象'L'。在plot(g,layout = gridLayout(L))这一行中,可能有一个我无法理解的问题。 – 2016-10-26 13:42:50