gpt4 book ai didi

r - 减少 ggpairs 图中的线条粗细和 'Corr:' 字体大小

转载 作者:行者123 更新时间:2023-12-01 11:47:19 24 4
gpt4 key购买 nike

我正在做一个 ggpairs 绘图,但回归线太粗并且“Corr:”文本字体太大。

data(mtcars)
head(mtcars)

mtcars$am <- as.factor(mtcars$am)

g <- ggpairs(
data = mtcars,
lower = list(
continuous = wrap("smooth", alpha = 0.3, color = "blue")
)
)
g <- g + theme(
axis.text = element_text(size = 6),
axis.title = element_text(size = 6),
legend.background = element_rect(fill = "white"),
panel.grid.major = element_line(colour = NA),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "grey95")
)
print(g, bottomHeightProportion = 0.5, leftWidthProportion = .5)

这是输出:

enter image description here

我在 GGally 中找不到我可以在其中设置的文档。

任何指针?

最佳答案

试试这个来增加字体大小:

data(mtcars)
head(mtcars)

mtcars$am <- as.factor(mtcars$am)

library(ggplot2)
library(GGally)

lowerFn <- function(data, mapping, ...) {
p <- ggplot(data = data, mapping = mapping) +
geom_point(color = 'blue', alpha=0.3, size=4) +
geom_smooth(color = 'black', method='lm', size=1,...)
p
}

g <- ggpairs(
data = mtcars,
lower = list(
continuous = wrap(lowerFn) #wrap("smooth", alpha = 0.3, color = "blue", lwd=1)
),
upper = list(continuous = wrap("cor", size = 5))
)
g <- g + theme(
axis.text = element_text(size = 6),
axis.title = element_text(size = 6),
legend.background = element_rect(fill = "white"),
panel.grid.major = element_line(colour = NA),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "grey95")
)
print(g, bottomHeightProportion = 0.5, leftWidthProportion = .5)

enter image description here

关于r - 减少 ggpairs 图中的线条粗细和 'Corr:' 字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39709745/

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