这是数据:
set.seed(123)
mat <- matrix(rnorm(5000, 0.5, 0.2), 50)
heatmap (mat)
![enter image description here](https://i.sstatic.net/1EDbu.jpg)
mat[mat > 0.05] <- NA
heatmap (mat)
Error in hclustfun(distfun(x)) :
NA/NaN/Inf in foreign function call (arg 11)
通过用其他值替换(任意可以帮助),但它可以欺骗读者,因为它会从相同的比例中选择颜色,这是不正确的。所以我想为那些大于 0.05 的值设置完全不同的颜色。
mat[mat > 0.05] <- 0.1
heatmap (mat)
![enter image description here](https://i.sstatic.net/tYSe5.jpg)
最佳答案
也许...
library(gplots)
set.seed(123)
mat <- matrix(rnorm(5000, 0.5, 0.2), 50)
heatmap.2(mat, breaks=c(-1,0.02,0.05,1), col=c("yellow", "red", "blue"),
# aiming for >0.05 is blue
dendrogram="both", trace="none")
基本上玩玩
col=
和 breaks=
好像:
![enter image description here](https://i.sstatic.net/WNiEg.png)
关于r - r 中某些值的具有自己颜色的热图图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10572862/