R corrplot colors range
Asked Answered
O

1

9

I am using corrplot in R to plot a correlation-coefficient matrix, but my correlations range only from 0.95 to 1.00, and I don't know how to set the lower and upper bounds of colors palette.

corrplot(segCorr, order = "hclust", tl.cex = .6, 
         cl.lim = c(0.95, 1), col=colorRampPalette(c("blue","white","red"))(10))

Despite of the settings everything is in one color, but I need to see these small differences in details.

Ossetic answered 6/11, 2016 at 16:55 Comment(1)
#28110147 seems to have a way... so try d = mvtnorm::rmvnorm(50, c(0,0, 0), matrix(c(1, 0.9, 0.9, 0.9, 1, 0.9, 0.9, 0.9, 1),3)) ; mypal = colorRampPalette(c("blue", "white", "red"))(10) ; color = rep(mypal, 100); corrplot(cor(d), order = "hclust", tl.cex = .6, cl.lim = c(0.85, 1),col=color)Staten
V
10

A "hack" I sometimes use, to avoid spending too much time setting a good color-pallete, is to set is.corr = FALSE. Then we get from

with(mtcars, corrplot(cor(cbind(disp, hp, cyl)), cl.lim = c(0.7, 1)))

enter image description here

to...

with(mtcars, corrplot(cor(cbind(disp, hp, cyl)), cl.lim = c(0.7, 1), is.corr = FALSE))

enter image description here

Verine answered 6/11, 2016 at 17:32 Comment(2)
Yup, great! Adding is.corr = FALSE to the parameters list of corrplot resolved my issue. Many thanks!Ossetic
For those trying to get this working, it seems cl.lim has been changed to col.lim on more recent versions of the corrplot packageSelfinsurance

© 2022 - 2024 — McMap. All rights reserved.