R igraph 布局未按预期执行

R igraph layouts are not performing as they should

我是 运行 在 r 中使用 igraph 的一些小图,我无法复制一些非常标准的布局函数。我的边缘长度不同,重叠而且很乱。我一直在努力寻找大约 1.5,但没有任何进展。下面的这个例子给了我这张图。

library(igraph)

set.seed(123)
x <- sample( LETTERS[1:4], 100, 
         replace=TRUE)
y <- sample( LETTERS, 100, 
         replace=TRUE)
mydata <- data.frame(x,y)

my.plot <- graph_from_data_frame(mydata,directed = F)
l <- layout_with_fr(my.plot)
plot(my.plot, layout=l)

我有大约 5 个与示例大小相同的网络。是否有布局函数可以 'facet' 类似于 ggplot2 的不同图形?

所以这不是没有答案...

你可以通过设置par(mfrow=c(2,3))得到你想要的效果。因为 igraph 往往会留下很大的边距,所以我建议也设置边距。因此,运行 包括您的 layout 声明在内的所有内容。那么

par(mfrow=c(2,3), mar=c(0,0,0,0)) 
for(i in 1:5) { plot(my.plot, layout=l) }

当然,我只是将同一件事绘制了 5 次。你会想要制作你的每一个不同的情节。