How can I change the plot range to be from 0 to 1 as the correlation matrix is always positive.
Script:
require(RColorBrewer)
library(corrplot)
set.seed(123)
data <- matrix(runif(100, min = 0, max = 1), nrow = 10)
df <- as.data.frame(data)
correlation_matrix <- cor(df)
correlation_matrix <- (correlation_matrix + 1) / 2
corrplot(correlation_matrix, method="circle", col = rep(rev(brewer.pal(n=8, name="RdYlBu")), 2))
This?
You can change the plot range using col.lim
variable, with the min and max as a vector i.e. =c(min, max)
.
corrplot(col.lim=c(0,1),correlation_matrix, method="circle", col = rep(rev(brewer.pal(n=8, name="RdYlBu")), 2))