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

Midpoint color is not white #228

Closed
bixiou opened this issue Nov 7, 2021 · 9 comments
Closed

Midpoint color is not white #228

bixiou opened this issue Nov 7, 2021 · 9 comments

Comments

@bixiou
Copy link

bixiou commented Nov 7, 2021

Hello,

considering the following code, I would wish that the cell "50" is white and the higher cells blue, but all cells are red (which should be limited to values lower than the middle 50). What am I doing wrong?

corrplot(matrix(c(0.8, 0.5, 0.6, 0.7), ncol=2), method='color', col.lim = c(0, 1), addCoef.col = 'black', addCoefasPercent = T, type="full", is.corr = F)

Rplot01

@bixiou
Copy link
Author

bixiou commented Nov 7, 2021

I have tested the same code on another computer (where corrplot's version is 0.84 instead of 0.90), and the result is even weirder. The example above works well... but when I change the values in the matrix, similar bugs reappear. See below.
Same code as above (produces the expected result:
Rplot!02

This one also works well:
Rplot

But this one bugs:
Rplot01

@taiyun
Copy link
Owner

taiyun commented Nov 10, 2021

Please read the manual.

col.lim

The limits (x1, x2) interval for assigning color by col. If NULL, col.lim will be c(-1, 1) when is.corr is TRUE, . col.lim will be c(min(corr), max(corr)) when is.corr is FALSE

NOTICE: if you set col.lim when is.corr is TRUE, the assigning color method is still distributed uniformly in [-1, 1], it only affect the display on color-legend.

is.corr

Logical, whether the input matrix is a correlation matrix or not. We can visualize the non-correlation matrix by setting is.corr = FALSE.

@taiyun taiyun closed this as completed Nov 10, 2021
@bixiou
Copy link
Author

bixiou commented Nov 10, 2021

I had read the manual, and corrplot does not behave like it should. Notice that in my examples, is.corr is set to FALSE. Hence, col.lim = c(0, 1) should be used. But it is not. Also, notice that in my example, the colors limit are not even set to c(min(corr), max(corr)) (in which case we would have a dark red and a dark blue cell in each example). So there really is a bug.
Can you provide a patch?

@taiyun taiyun reopened this Nov 10, 2021
@taiyun taiyun closed this as completed in dadf8f6 Nov 10, 2021
taiyun added a commit that referenced this issue Nov 10, 2021
@taiyun taiyun reopened this Nov 10, 2021
@taiyun
Copy link
Owner

taiyun commented Nov 10, 2021

@bixiou Can you try the latest version corrplot on github?

Here are some examples that works well.

corrplot(matrix(c(0.8, 0.5, 0.6, 0.7), ncol=2), method='color', 
         col.lim = c(0, 1), addCoef.col = 'black', addCoefasPercent = T, 
         type="full", is.corr = F)

corrplot(matrix(c(0.2, 0.4, 0.6, 0.8), ncol=2), method='color', 
         col.lim = c(0, 1), addCoef.col = 'black', addCoefasPercent = T, 
         type="full", is.corr = F)

corrplot(matrix(c(1:9)/10, ncol=3), method='color', 
         col.lim = c(0, 1), addCoef.col = 'black', addCoefasPercent = T, 
         type="full", col = COL2('RdYlBu'), is.corr = F)

corrplot(matrix(c(1:9)/10, ncol=3), method='color', 
         col.lim = c(0, 1), addCoef.col = 'black', addCoefasPercent = T, 
         type="full",  is.corr = F)

@bixiou
Copy link
Author

bixiou commented Nov 10, 2021

The install failed, but I copy/pasted the code of corrplot() from github and it works. Thank you!

FYI, here is the install error:
E> * creating vignettes ... ERROR
E> --- re-building 'corrplot-intro.Rmd' using rmarkdown
E> Error: processing vignette 'corrplot-intro.Rmd' failed with diagnostics:
E> no package named 'prettydoc' can be found
E> --- failed re-building 'corrplot-intro.Rmd'
E>
E> RESUME : le traitement du fichier suivant a échoué :
E> 'corrplot-intro.Rmd'
E>
E> Erreur : Vignette re-building failed.

@taiyun
Copy link
Owner

taiyun commented Nov 10, 2021

You should install prettydoc package first.

Thanks again.

@taiyun
Copy link
Owner

taiyun commented Nov 11, 2021

@bixiou I updated corrplot to v0.92 on Github. You can test this bug further if you have time.

@bixiou
Copy link
Author

bixiou commented Nov 11, 2021

It works well, thank you!

@taiyun
Copy link
Owner

taiyun commented Nov 11, 2021

OK. Thanks.

@taiyun taiyun closed this as completed Nov 11, 2021
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