我正在R库中构建一个简单的热图。 这是我的矩阵:
stleft = matrix(
c(0,5,5,2,6,8,4,6,9),
nrow=3,
ncol=3)
colnames(stleft) <- c("Narrow","Wide", "Wider")
rownames(stleft) <- c("Person", "Object","Bare")
stleft
矩阵如下:
> stleft
Narrow Wide Wider
Person 0 2 4
Object 5 6 6
Bare 5 8 9
要构建热图,我只需运行:
par(oma=c(3, 0, 0, 3))
col <- rev(heat.colors(999))
heatmap(stleft, Colv = NA, Rowv = NA, scale = "none")
您知道如何将矩阵的数字插入热图的单元格吗?