Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifying the color range #255

Closed
imilenkovic opened this issue Aug 10, 2022 · 6 comments
Closed

specifying the color range #255

imilenkovic opened this issue Aug 10, 2022 · 6 comments

Comments

@imilenkovic
Copy link

Hello,

I was wondering if it would be possible to specify the range in which a color gradient will be applied?
For example:
image

in this plot the range is from 1 to -1, but I would like to only have it eg. from 1 to -0.15, so that the values around 0 are bright yellow and values around 1 are brown?

Thank you.

@imilenkovic
Copy link
Author

This was the code:

corrplot(cor(merged2), # Correlation matrix
method = "shade", # Correlation plot method
type = "full", # Correlation plot style (also "upper" and "lower")
diag = TRUE, # If TRUE (default), adds the diagonal
tl.col = "black", # Labels color
bg = "white", # Background color
title = "", # Main title
#col.lim = c(0.9,1),
is.corr = FALSE,
COL1(sequential = c("YlOrBr"))) # Color palette

@taiyun
Copy link
Owner

taiyun commented Aug 18, 2022

You can set col.lim.

Examples: https://taiyun.github.io/corrplot/

@imilenkovic
Copy link
Author

Hello,

When I set col.lim, the colour distribution stays the same.

corrplot(cor(merged2),        # Correlation matrix
         method = "shade", # Correlation plot method
         type = "full",    # Correlation plot style (also "upper" and "lower")
         diag = TRUE,      # If TRUE (default), adds the diagonal
         tl.col = "black", # Labels color
         bg = "white",     # Background color
         title = "",       # Main title
         col.lim = c(-0.15,1),
         is.corr = FALSE,
         COL1(sequential = c("YlOrBr")))        # Color palette

image

When changing is.corr to TRUE, it's still the same:

corrplot(cor(merged2),        # Correlation matrix
         method = "shade", # Correlation plot method
         type = "full",    # Correlation plot style (also "upper" and "lower")
         diag = TRUE,      # If TRUE (default), adds the diagonal
         tl.col = "black", # Labels color
         bg = "white",     # Background color
         title = "",       # Main title
         col.lim = c(-0.15,1),
         is.corr = TRUE,
         COL1(sequential = c("YlOrBr")))        # Color palette

image

I assume that I would have to use diverging colours here, but the same colour palette doesn't exist with diverging colours. I already made many other plots with this colour scheme so I would prefer to stick to the same colours if at all possible. Thanks!

@taiyun
Copy link
Owner

taiyun commented Aug 29, 2022

Please update the new version v0.93 from Github. And set ignoreSign = TRUE.

@taiyun taiyun closed this as completed in f887816 Aug 29, 2022
@taiyun taiyun reopened this Aug 29, 2022
@imilenkovic
Copy link
Author

imilenkovic commented Aug 29, 2022

Hello,

I updated the package and ran the following:

corrplot(cor(merged2),        # Correlation matrix
         ignoreSign = TRUE,
         method = "shade", # Correlation plot method
         type = "full",    # Correlation plot style (also "upper" and "lower")
         diag = TRUE,      # If TRUE (default), adds the diagonal
         tl.col = "black", # Labels color
         bg = "white",     # Background color
         title = "",       # Main title
         col.lim = c(-0.2,1),
         is.corr = FALSE,
         COL1(sequential = c("YlOrBr")))   

and got the following warning

Warning message: In corrplot(cor(merged2), ignoreSign = TRUE, method = "shade", type = "full", : col.lim interval not suitable to the matrix

The plot now looks like this:

image

So all good, thanks a lot!

@taiyun
Copy link
Owner

taiyun commented Aug 31, 2022

Please update the new version v0.93 from Github. And set ignoreSign = TRUE.

ignoreSign = TRUE is very easy to misunderstood.

I rename it, please set transKeepSign = FALSE after updating. Like:

merged2 = matrix(runif(100,-0.18,0.99),10,10)
corrplot(merged2,          # Correlation matrix
         method = "color", # Correlation plot method
         type = "full",    # Correlation plot style (also "upper" and "lower")
         diag = TRUE,      # If TRUE (default), adds the diagonal
         tl.col = "black", # Labels color
         bg = "white",     # Background color
         title = "",       # Main title
         col.lim = c(-0.2,1),
         cl.length = 13,
         is.corr = FALSE,
         transKeepSign = FALSE,
         COL1(sequential = c("YlOrBr")))        # Color palette

Rplot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants