Remove text labels of variables on diagonal corrplot
1
1
Entering edit mode
7.3 years ago
Jack ▴ 120

How can I remove text labels from diagonal only on corrplot?

my_correlation_matrix1 <- read.table("path/to/matrix", header = T)
my_correlation_matrix2 <- read.table("path/to/matrix", header = T)

corrplot(my_correlation_matrix1,
         method = "color",                                    
         type = "lower",                                      
         tl.col = "black",                                    
         tl.cex = 0.6,                                        
         tl.srt = 45)

corrplot(my_correlation_matrix2,
         method = "color",                                    
         type = "lower",                                      
         tl.col = "black",                                    
         tl.cex = 0.6,                                        
         tl.srt = 45,
         add = T)

Since I'm using add = T, the 2 corrplots are merged in one plot. But because they have values on the diagonal, they are overlapping. How can this be fixed?

What I'm trying to do, is merge 2-corrplots-in-1. Two different studies for the same set of values. Upper triangular is measurement A and lower is measurement B.

R cORRPLOT • 4.7k views
ADD COMMENT
0
Entering edit mode

Not completely sure what you want to do but you could try modifying the values in the diagonal of your correlation matrix. Use diag to access the diagonal: diag(my_matrix) <- <some_new_value>

ADD REPLY
0
Entering edit mode

@ddiez I've updated the question. check it again.

ADD REPLY
0
Entering edit mode

Added an tentative answer. I assumed there is a typo in your code above and the second call to corrplot sets type = "upper". Is that correct?

ADD REPLY
0
Entering edit mode
7.3 years ago
ddiez ★ 2.0k

I do not know enough about corrplot to solve your problem tweaking the function's arguments. But instead, why don't you try making a new matrix containing the information you want to plot, and use a single call to corrplot? For example:

m <- my_correlation_matrix1
m[upper.tri(m)] <- my_correlation_matrix2[upper.tri(my_correlation_matrix2)]
m
corrplot(m,
         method = "color",
         tl.col = "black",                                    
         tl.cex = 0.6,                                        
         tl.srt = 45)
ADD COMMENT

Login before adding your answer.

Traffic: 2711 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6