gpt4 book ai didi

r - 在 ggpairs() 中调整组文本美学

转载 作者:行者123 更新时间:2023-12-05 04:06:59 24 4
gpt4 key购买 nike

我正在使用 ggpairs() 为一组变量创建散点图和相关性。我的相关图上的文本不适合绘图区域,因为它们被水平调整以在绘图的中途结束。我在 another post 上看到了如何调整顶线关联文本,但它对组关联不起作用。

这是一个例子:

n = 1000
test_results = tibble(
test1=sample(1:10, n, replace=TRUE),
test2=sample(1:10, n, replace=TRUE),
test3=sample(1:10, n, replace=TRUE),
test4=sample(1:10, n, replace=TRUE),
test5=sample(1:10, n, replace=TRUE),
political=sample(c("Democrat", "Republican", "Green", "Libertarian"), n, replace=TRUE))

test_results %>%
select(test1, test2, test3, test4, test5, political) %>%
ggpairs(columns=c(1:5), mapping = aes(color = political, alpha=.5),
upper = list(continuous = wrap("cor", size = 3, hjust=0))
)

Group correlation text off of image

最佳答案

从@jrlewi 链接的代码来看,答案似乎是alignPercent!

test_results %>% 
select(test1, test2, test3, test4, test5, political) %>%
ggpairs(columns=c(1:5), mapping = aes(color = political, alpha=.5),
upper = list(continuous = wrap("cor", size = 3, hjust=0.15, alignPercent=1))
)

Properly aligned text

关于r - 在 ggpairs() 中调整组文本美学,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49213418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com