简体   繁体   English

如何使用 ggnet2 设置固定节点位置

[英]How to set fix node positions with ggnet2

I am using ggnet2 to visualize networks and I was wondering whether anyone is aware of a way to fix the node positions as it is possible with eg igraph (as explained eg here How to control the igraph plot layout with Fixed Positions? )我正在使用 ggnet2 来可视化网络,我想知道是否有人知道一种修复节点位置的方法,因为它可以使用例如 igraph(如这里解释的那样如何使用固定位置控制 igraph 绘图布局?

Thanks, Chris谢谢,克里斯

I had the same problem myself and fixed it by setting the random seed. 我自己也遇到了同样的问题,并通过设置随机种子来解决。 Apparently ggnet2 randomly distributes the nodes in line with the selected algorithm-mode. 显然,ggnet2根据所选算法模式随机分配节点。 So to get reproducible that is to say identical plots just always use set.seed() before every plot. 因此,要获得可复制性,即相同的图,总是在每个图之前使用set.seed()

eg: 例如:

set.seed(1)
ggnet2(net)

Ok, this is an old question but in case anyone looks for the answer...好的,这是一个老问题,但万一有人在寻找答案......

Make a matrix of the coordinates:制作坐标矩阵:

l = as.matrix(data.frame(x = c(0.1,0.1, 0.5, 0.8), y = c(0.75, 0.25, 0.5, 0.5)))

Use利用

ggnet2(net, mode = l)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM