# How to change corrplot() color limits and color scale

Created @September 27, 2021 4:00 PM CorrelationR

Allow me to walk you through the process of generating this `corrplot()` with custom color limits and color pallete:

I was working on making a correlation plot to show that the RNA-seq profiles of different cells types within an experiment are similar. So I naturally used the `corrplot()` function in R with the correlation matrix of the RNA-seq values. They were all positively correlated so it it was a little hard to see the differences in correlation , R, when visualized. Here is the code:

``````# extracting the RNA seq values from the Variance stabilized counts from DESeq2
mat = VarianceStabilizedCounts[, 3:ncol(VarianceStabilizedCounts)]

# calculcating the correlation matrix
cor.mat = cor(mat, method = "spearman")

# creating the correlation matrix
corrplot(cor.mat,
type = "upper",
t1.col = "white",
title = "\n\n\n",
is.corr = TRUE,
order = "hclust",
diag = TRUE)``````

As you can see the entire bottom half of the scale is not used because all values are roughly above 0.3. So I started playing around with the `corrplot()` parameters to see if I could change the scale from (-1,1) to (0.3, 1)

``````corrplot(cor.mat,
type = "upper",
t1.col = "white",
title = "\n\n\n",
is.corr = TRUE,
order = "hclust",
col.lim = c(0.3,1),  ##added this line
diag = TRUE)``````

While this did change the color scale values, the colors did not change as I expected. After much googling, I came across this post . (Note: in `cl.lim` referred to in this post is `col.lim` in the version of `corrplot()` I used).

``````corrplot(cor.mat,
type = "upper",
t1.col = "white",
title = "\n\n\n",
is.corr = FALSE, ## changed this line
order = "hclust",
col.lim = c(0.3,1),
diag = TRUE)``````

And this helped to actually "squish" the color scale to match the color limits!

I changed a couple other parameters to add the correlation coefficient and change the color scale

``````corrplot(cor.mat,
type = "upper",
title = "\n\n\n",
is.corr = FALSE,
order = "hclust",
col.lim = c(0.3,1),
col = colorRampPalette(c("white", "deepskyblue", "blue4"))(100),