Search code examples
rr-corrplot

R package corrplot - headmap color and lower triangular variable names


I have two questions concerning the package corrplot:

1) How do I make the colors of the headmap contrast more? Everything in the range from -0.2 to 0.2 is hardly visible.

2) I want just half of the correlation matrix. If I change the type to "lower" the variable names come down. However I still want them to be up, like a regular rectangle.

Attached as screenshot.


Solution

  • 1) In the documentation of corrplot there are several examples of how to change color scales. It's easy to create your own color scales. Here's just one possible example:

    require(corrplot)
    data(mtcars)
    M <- cor(mtcars)
    col <- colorRampPalette(c("red", "blue"))
    corrplot(M, col = col(10))
    

    2) You can easily change the position of the labels and the color scale using the arguments tl.pos and cl.pos respectively. For example:

    corrplot(M, col = col(10), type = "lower", cl.pos = "r", tl.pos = "lt")