How to insert a white gap between specific columns in a plot of corrplot?

61 Views Asked by At

I want to add a white gap as a separator between specific columns in the correlation heatmap generated by corrplot in R.

Code:

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

Image1

  1. I want a white gap between the second and third columns as shown below.

Image2

Is there any way to do this in R?

1

There are 1 best solutions below

2
TarJae On

We could do it this way: Just enter a column with zeros:

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

corrplot(M, method = 'number')

enter image description here