Ron*_*uza 4 plot r igraph gephi
我有一个具有以下特征的网络(igraph):
>g
IGRAPH DN-- 3370 16699 --
+ attr: name (v/c), grupo (v/n), year (v/n), grupo.freq (v/n),
grupo.perc (v/n), vertex.frame.size (v/n), color (v/c),
vertex.frame.color (v/c), grupo (e/n), year (e/n), color (e/c)
Run Code Online (Sandbox Code Playgroud)
make clustering 后有以下组:
>table(V(g)$grupo)
1 2 8
1516 1367 487
Run Code Online (Sandbox Code Playgroud)
我对能够突出群体之间关系的观点感兴趣(V(g)$grupo)
。我使用该软件Gephi
来布局Force Atlas 2
下一张图片:
https://i.stack.imgur.com/GQxyT.png
我的问题是,如何在 R 中得到类似的结果?
我正在使用以下代码:
colbar <- rainbow(length(table(V(g)$grupo)))
V(g)$color <- colbar
E(g)$color <- colbar
V(g)$vertex.frame.color <- colbar
V(g)$vertex.frame.size <- 0.1
plot.igraph(
g,
layout=layout.fruchterman.reingold.grid,
vertex.label=NA,
vertex.size=1,
edge.lty=1,
edge.arrow.size=0.0000001
)
Run Code Online (Sandbox Code Playgroud)
点击链接下载我在csv
或 中使用的数据Rdata
:
http: //www.datafilehost.com/d/855e3e86
首先,获取ForceAtlas2包。
install.packages("devtools")
if (!require("ForceAtlas2")) devtools::install_github("analyxcompany/ForceAtlas2")
library("ForceAtlas2")
Run Code Online (Sandbox Code Playgroud)
然后,要使用布局渲染图形,g
请l
执行以下操作(此处包含所有可用的布局参数):
g <- erdos.renyi.game(1000, 1/1000)
l <- layout.forceatlas2(g, directed=TRUE, iterations = 100,
linlog = FALSE, pos = NULL, nohubs = FALSE,
k = 400, gravity=1, ks=0.1, ksmax=10, delta = 1,
center=NULL, tolerance = 0.1, dim = 2,
plotstep=10, plotlabels=TRUE)
plot(g,layout=l)
Run Code Online (Sandbox Code Playgroud)
如果您愿意,您可以vertex.size = 3, vertex.color = "red"
为绘图函数提供诸如此类的选项。