taiyun / corrplot

A visual exploratory tool on correlation matrix
https://github.com/taiyun/corrplot
Other
316 stars 86 forks source link

Changing color of specific correlation values #121

Closed DemaLM closed 3 years ago

DemaLM commented 6 years ago

Hi, I'd like to point out some specific values in the matrix by changing the color of that specific cells (values) in the matrix. Hence, is it possible to change the color of a specific position/values in the matrix?

Let's say I have the following correlation matrix:

a<-matrix(runif(100, min=-1, max=1),c(10,10))
b<-matrix(runif(100, min=-1, max=1),c(10,10))

a2<-a[lower.tri(a)]; a2

b2<-b[upper.tri(b)];b2

d<-c(runif(10, min=-1, max=1))

c<-matrix(rep(NA,100), c(10,10))
c[lower.tri(c)]<-a2
c[upper.tri(c)]<-b2
diag(c)<-d
c
corrplot(c, method = 'color', addCoef.col = "grey20",  
            col = RColorBrewer::brewer.pal(n = 8, name = "RdYlBu"))

I want the color to indicate groups not the strength of the correlation because I already have value of the correlations in each square. So I would like to have a color for the lower triangle of c (a2 values), another color for upper triangle of c (b2 values) and a third color for the diagonal (d values)

I appreciate the help!

taiyun commented 3 years ago

You can do this with image editing software after corrplot