我有两个具有相同维度、列名和行名的矩阵,如下所示。
data(mtcars)
M <- cor(mtcars)
myMat<-matrix(runif(11*11), ncol=11)
colnames(myMat) <- colnames(M)
rownames(myMat) <- rownames(M)我想使用一个矩阵图来可视化两个矩阵,如下所示
corrplot(M, method = "circle")我想做一个新的图,其中圆的颜色基于M矩阵,大小基于myMat矩阵。有没有办法在R语言中实现这一点。
发布于 2016-09-15 21:38:00
使用ggplot转换为长格式并绘制:
library(ggplot2)
long <- cbind(as.data.frame.table(M, responseName = "cor"), myMat = c(myMat))
ggplot(long, aes(Var1, Var2, col = cor, size = myMat)) +
geom_point() +
scale_colour_gradient(low = "red", high = "blue") +
xlab("") +
ylab("")给予:

https://stackoverflow.com/questions/39507673
复制相似问题