【问题标题】:igraph in R: Making image() plot an adjacency matrix with the axis starting in the top-left instead of the bottom-left corner?R中的igraph:制作image()绘制一个邻接矩阵,轴从左上角而不是左下角开始?
【发布时间】:2018-07-04 14:42:43
【问题描述】:

我在R 中使用igraph 来使用随机块模型作为生成邻接矩阵的基础。在矩阵本身中,行从左上角开始向下,而列从左上角开始向右。当我使用image()R 中绘制它时,方向与常规矩阵的方向不匹配。相反,它的轴从左下角开始。

library(igraph)
pm <- matrix(rep(0.9, 100*100), ncol = 100)
diag(pm) <- rep(0.01, 100)
g <- sample_sbm(1000, pref.matrix = pm, block.sizes = rep(1000/100,100))
A <- as.matrix(as_adj(g))
image(A, useRaster = T)

有没有办法让image()从左上角开始?

【问题讨论】:

  • 反转 y 轴? image(A, ylim=c(1,0), useRaster = TRUE)
  • 对不起,我的意思是如果有办法将上面的红色对角线绘制为从左上角到右下角——类似于转置?谢谢!

标签: r igraph


【解决方案1】:

您可以通过颠倒行或列的顺序来翻转图像而不翻转轴

image(A[,ncol(A):1], useRaster = TRUE)
image(A[nrow(A):1,], useRaster = TRUE)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 2021-12-01
    • 1970-01-01
    • 2017-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多