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

Could these text labels on the diagonal be Customized? #8

Open
DickRLee opened this issue Apr 24, 2022 · 3 comments
Open

Could these text labels on the diagonal be Customized? #8

DickRLee opened this issue Apr 24, 2022 · 3 comments

Comments

@DickRLee
Copy link

Thank you so much for such a detailed user guide, it is very helpful for beginners like me. I'm a microbial ecology researcher and often deal with longer microbiology terms. I like the lower triangle graph in your package, but the text labels on the diagonal in it don't perform very well when the words are very long. Is there any parameter that I can use to choose to hide the diagonal text labels or adjust their position? Thank you very much!
https://github.com/caijun/ggcorrplot2/blob/master/figs/README-unnamed-chunk-2-6.png

@LDSamson
Copy link
Contributor

LDSamson commented May 3, 2022

I tried to implement changes to address this issue here. You can try this out locally by installing:

devtools::install_github("LDSamson/ggcorrplot2@improve_labels")

It is not perfect, but it has some changes so that longer labels are slightly better supported. The labels are rotated by default (which is also the default behavior of the original corrplot package). Some labels can still be cut off, especially the first ones on top. I tried to mitigate that to dynamically assign additional plot padding, based on label length.

library(ggcorrplot2)
data(mtcars)
library(psych)
ct <- corr.test(mtcars, adjust = "none")
corr <- ct$r
p.mat <- ct$p

# example long labels:
colnames(corr) <- paste0(colnames(corr), "longlabel", sep = "")
rownames(corr) <- colnames(corr)
ggcorrplot(corr, type = "lower")

long_lable_fig

What do you think @caijun ?

@LDSamson LDSamson mentioned this issue May 3, 2022
@caijun
Copy link
Owner

caijun commented May 6, 2022

@LDSamson thanks for your implementation. I have merged your PR.

@caijun
Copy link
Owner

caijun commented May 7, 2022

@DickRLee You may try the latest version of ggcorrplot2.

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

3 participants