我正在绘制两个矩阵对的组合,并希望指定行范围的颜色。我提出了对我来说似乎很难看的解决方案。有什么建议可以直接指定要根据指定颜色着色的行(或/和列)范围吗?先感谢您!
# C - is combination of two matrices A and B
C <- rbind(A,B)
C_f <- as.factor(c(rep("label1",nrow(A)),rep("label2",nrow(B))))
pairs(C, col=c("red", "blue")[C_f])
# EDIT: added matrix generation as thelatemail asked
A<-matrix(sample(1:100,rep=T),10,10)
B<-matrix(sample(1:200,rep=T),20,10)
C<-rbind(A,B)