Changing Color of Selected Column Names in Corrplot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing Color of Selected Column Names in Corrplot

Lorenzo Isella
Dear All,
Please consider the following example


library(corrplot)
M <- cor(mtcars)
corrplot(M, method="circle", type="lower", diag=F)


Suppose that I want to have the label "mpg" at the top in black
and leave everything else in red.
How can I achieve that?
Cheers

Lorenzo

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Changing Color of Selected Column Names in Corrplot

David Carlson
Hopefully someone has a cleaner approach, but this will work. You have to remove the first column/row labels and print with text():

library(corrplot)
M <- cor(mtcars)
colnames(M)[1] <- ""
rownames(M)[1] <- ""
corrplot(M, method="circle", type="lower", diag=F)
text(1, dim(M)[1] - .1, "mpg", srt=90, xpd=TRUE)

# Replace first row/colnames if you will be using M later
colnames(M)[1] <- "mpg"
rownames(M)[1] <- "mpg"

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352


-----Original Message-----
From: R-help [mailto:[hidden email]] On Behalf Of Lorenzo Isella
Sent: Friday, June 16, 2017 8:55 AM
To: [hidden email]
Subject: [R] Changing Color of Selected Column Names in Corrplot

Dear All,
Please consider the following example


library(corrplot)
M <- cor(mtcars)
corrplot(M, method="circle", type="lower", diag=F)


Suppose that I want to have the label "mpg" at the top in black
and leave everything else in red.
How can I achieve that?
Cheers

Lorenzo

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.