ggcorrplot2 icon indicating copy to clipboard operation
ggcorrplot2 copied to clipboard

Could these text labels on the diagonal be Customized?

Open DickRLee opened this issue 3 years ago • 3 comments

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

DickRLee avatar Apr 24 '22 15:04 DickRLee

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 avatar May 03 '22 11:05 LDSamson

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

caijun avatar May 06 '22 16:05 caijun

@DickRLee You may try the latest version of ggcorrplot2.

caijun avatar May 07 '22 11:05 caijun