如何在 corrplot 图中的特定列之间插入白色间隙?

问题描述 投票:0回答:1

我想在

corrplot
在 R 中生成的相关热图中添加一个白色间隙作为特定列之间的分隔符。

代码:

library(corrplot)
M = cor(mtcars)
corrplot(M, method = 'number')
  1. corrplot

Image1

  1. 我想要第二列和第三列之间有一个白色间隙,如下所示。

Image2

在 R 中有什么方法可以做到这一点吗?

r plot heatmap r-corrplot gap-system
1个回答
0
投票

我们可以这样做:只需输入一个带零的列:

library(corrplot) 
M <- cor(mtcars) 
M <- cbind(M[, 1:2], rep(0, nrow(M)), M[, 3:ncol(M)])

corrplot(M, method = 'number')

© www.soinside.com 2019 - 2024. All rights reserved.