Reputation: 31
I have done the following visualization of a correlation matrix:
a <- c(1,2,3,4)
b <- c(5,6,7,8)
data <- data.frame(a, b)
M <- cor(data, method = "spearman")
corrplot(M, method = "color")
Now, the legend of the variables appears in red, which I would like to change to black. Also, I would like to change the names of the variables.
I have looked around for possible solutions but have found nothing yet. As I am rather new to R, I do not know how to solve this myself. Does anybody know how I can do this?
Upvotes: 1
Views: 962
Reputation: 85
M <- cor(data, method = "spearman")
corrplot(M, method = "color",
col=colorRampPalette(c("blue","yellow"))(200),
tl.col=c("black", "black", "black", "black"))
tl.col argument allows user to change the color of each variable
col argument allows the user to change the color of the correlation plot
Upvotes: 3
Reputation: 78927
You could define your own colorRampPalette
:
library(corrplot)
# newdata
a <- c(18,82,3,4)
b <- c(5,6,97,89)
data <- data.frame(a, b)
M <- cor(data, method = "spearman")
colnames(M) <- c("AAAAAAAA", "BBBBBBBBBBBB")
rownames(M) <- c("Bla", "BlaBla")
corrplot(M, method = "color", col=colorRampPalette(c("blue","white","black"))(200))
Upvotes: 2