我试图制作这种结果的热图:
set.seed(123)
x<-sample(c(rep(0, 1000), rep(1, 90), rep(2, 60), rep(3, 60), rep(4:7, 10)), 1000,
replace=T)
x<-matrix(x, 200,5)
x<-x[!duplicated(x),]
head(x)
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 6 0 0
[2,] 0 3 0 0 0
[3,] 0 0 2 0 0
[4,] 2 0 0 0 0
[5,] 3 0 0 0 0
[6,] 0 2 0 1 4
其中1:7表示存在三种物种:
1=type1
2=type2
3=type3
4=type1+type3
5=type1+type2
6=type2+type3
7=type1+type2+type3
我使用三色系统制作热像图,如:
1=green
2=blue
3=red
4=green/red (like up diagonal is green and lower diagonal is red)
5=green/blue
6=blue/red
7=green/blue/red
我的问题是如何将这些组合颜色应用到热图单元格中?
heatmap(x, Colv=NA)