【问题标题】:Fixes positions for nodes in r igraph?修复 r igraph 中节点的位置?
【发布时间】:2016-02-08 12:13:48
【问题描述】:

假设我们想要可视化如下所示的网络

library(igraph)
a<- cbind(c(1,2,3,4,5),
c(2,4,1,2,2))
b<- graph.edgelist(a, directed=FALSE)

除了手动设置坐标之外,还有什么方法可以让节点保持在相同的位置?例如,我们是否可以使用 tkplot 编辑图形并保存布局,以便无论我们运行多少次代码都保持不变?通过使用函数 tkplot.getcoords,我设法只保存了一次布局。可重复性可能吗?

提前谢谢你。

【问题讨论】:

  • 考虑到tkp &lt;- tkplot(b); coords &lt;- tkplot.getcoords(tkp),可以备份变量coords。或者你是什么意思?

标签: r nodes igraph fixed


【解决方案1】:

解决方案是使用set.seed 设置种子:

library(igraph)
a<- cbind(c(1,2,3,4,5),
c(2,4,1,2,2))
b<- graph.edgelist(a, directed=FALSE)

set.seed(123)
plot(b)

每次运行代码时都会得到这个:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-14
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多