在做矩阵运算时,我希望能够看到我的计算结果是什么,至少能够粗略地了解进入和运行的矩阵的性质。如何轻松地可视化矩阵?
如何绘制实数矩阵,以便x轴表示列,y表示行,并且点的颜色或大小表示单元格值?
最终,我想显示多个图,例如,方程的右侧和左侧。
下面是一些示例代码:
a <- matrix(rnorm(100), ncol = 10)
b <- diag(1,10)
c <- a*b
par(mfrow = c(1,3))
plot.matrix.fn <- function(m) {
#enter answer to this question here
}
lapply(list(a,b,c), plot.matrix.fn)
更新时间:自发布这个问题,我发现有一些很好的例子在这里:What techniques exists in R to visualize a "distance matrix"?
看看这篇最近的帖子。 http://stackoverflow.com/questions/6883618/plotting-a-heat-map-for-an-upper-or-lower-triangular-matrix –