I am trying to plot in R a correlation matrix using the corrplot
package.
My problem is that the range of min and max correlation coefficients of the entire matrix is (-0.2,0.2). I plot the matrix with corrplot
and I use a custom colorRampPalette
, say
col1<-colorRampPalette(c('red','yellow','green','blue'))
for the colormap of the legend, so I set col=col1(10)
, and I set cl.lim=c(-0.2,0.2)
.
When I see the plot however the colorlegend appears from -0.2 to 0.2 but with just 2 colors, instead what I would like is a colorlegend with the entire spectrum of colors in 10 bins of the custom palette but in range (-0.2,0.2) so instead of having just 2 colors I will have 10 colors.
The solution for this was duplicate the color range, so, the get the second half...
mypal = jet.colors(1000) # jet.colors from library(matlab)
color = c(mypal,mypal)
corrplot(M, col=color)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With