R: corrplot.mixed: 如何保持显示的列名和行名,以及如何使对角线的颜色与其他颜色不同

R: corrplot.mixed: how do I keep the column names and row names displayed, and how do I make the diagonal have a different color than the rest

如果我像这样在 R 中制作常规相关图,它会正常显示列名和行名:

dat <- matrix(scan(),3,byrow=TRUE)
.06 .36 .07 
.10 .03 -.34
.20 .4  -.20

colnames(dat) <- c("a","b","c")
rownames(dat) <- c("a","b","c")

corrplot(dat, method="circle")

但是,如果我制作混合图,上半部分包含圆圈,下半部分 + 对角线作为数字,标签会消失:

corrplot.mixed(dat, lower="number", upper="circle",diag = "l")

我的主要问题是:如何将列标签和行标签显示在与第一个图中相同的位置?

关于此示例的第二个问题:是否可以将对角线显示为未根据相关性着色的数字,并让它们显示为黑色。

非常感谢!

您可以将参数 tl.pos ="lt" 添加到对 corrplot.mixed 的调用中。这使得标签出现在顶部和左侧。其他选项是 d 用于对角线和 [​​=14=] 用于 none.

因此,您的代码变为:

corrplot.mixed(dat, lower="number", upper="circle", diag = "l", tl.pos = "lt")