admin管理员组文章数量:1123768
When I use the ggpairs function in ggally, the result will always contain an “overall” extreme result of the data: corr:***. This is not always appropriate (needed) after analyzing the data grouping. I recently read an article with the same situation, and all I can think of at the moment is to export the PDF file and then process it. Does anyone have a more straightforward approach?
This figure comes from:
For comparison, the official package example has a 'corr:**' result after the grouping:
When I use the ggpairs function in ggally, the result will always contain an “overall” extreme result of the data: corr:***. This is not always appropriate (needed) after analyzing the data grouping. I recently read an article with the same situation, and all I can think of at the moment is to export the PDF file and then process it. Does anyone have a more straightforward approach?
This figure comes from:https://www.nature.com/articles/s41559-023-02253-z
For comparison, the official package example has a 'corr:**' result after the grouping:
Share Improve this question edited 21 hours ago stefan 123k6 gold badges36 silver badges72 bronze badges Recognized by R Language Collective asked yesterday BreezeBreeze 1296 bronze badges 2- You just want the cells above the diagonal to be blank? – Eonema Commented yesterday
- I apologize for the unclear content of my expression. I edited the question. It's not that the top of the diagonal is completely blank, but that some of the data ( corr:*** ) in it is not necessarily needed after grouping. – Breeze Commented yesterday
1 Answer
Reset to default 1Here is one (hacky??) option which removes the title aka the overall correlation using title_args = list(x = NA, na.rm = TRUE)
, then fixes the position of the group correlations using the group_args=
argument of ggally_cor
.
Using a minimal reprex based on iris
:
library(ggplot2)
library(GGally)
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
dat <- iris[c(1:3, 5)]
names(dat) <- c(paste0("tars", 1:3), "Species")
ggpairs(
data = dat,
mapping = aes(color = Species),
columns = 1:3,
upper = list(continuous = wrap(
ggally_cor,
group_args = list(
y = I(seq(.2, .8, length.out = length(unique(dat$Species))))
),
title_args = list(x = NA, na.rm = TRUE)
))
)
版权声明:本文标题:r - Adjustment of the correlation data labeling content in the upper right corner of ggpairs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736595930a1945149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论