gpt4 book ai didi

r - 显示facet_grid中每个图的x轴和y轴

转载 作者:行者123 更新时间:2023-12-02 07:43:45 25 4
gpt4 key购买 nike

由于之前曾提出过类似的问题(here),但我无法根据我的具体问题调整那里提供的解决方案。对于下面显示的每个图,都应该有 x 轴和 y 轴。

数据:

df_nSubj <- data.frame(
nSubj = rep(seq(10L, 50L, by = 10L), each = 24L),
family = factor(rep(rep(c("AOV", "MLM1", "MLM2", "MLM3"), 5), each = 6L)),
Spher = factor(rep(rep(c("met", "vio"), 20), each = 3L)),
effSize = rep(c(0.2, 0.5, 0.8), 40),
pow = c(
0.12, 0.53, 0.84, 0.1, 0.4, 0.74, 0.13, 0.55, 0.84, 0.11, 0.44, 0.74, 0.12,
0.5, 0.82, 0.1, 0.43, 0.76, 0.12, 0.49, 0.81, 0.1, 0.43, 0.76, 0.2, 0.84,
0.99, 0.15, 0.72, 0.97, 0.21, 0.81, 0.98, 0.17, 0.69, 0.95, 0.2, 0.83, 0.99,
0.17, 0.75, 0.97, 0.19, 0.82, 0.99, 0.17, 0.75, 0.97, 0.32, 0.95, 1, 0.23,
0.87, 1, 0.32, 0.92, 1, 0.25, 0.83, 0.99, 0.3, 0.94, 1, 0.24, 0.89, 1, 0.3,
0.94, 1, 0.24, 0.89, 1, 0.41, 0.99, 1, 0.29, 0.96, 1, 0.4, 0.97, 1, 0.3, 0.92,
1, 0.38, 0.99, 1, 0.32, 0.97, 1, 0.37, 0.98, 1, 0.32, 0.97, 1, 0.5, 1, 1,
0.36, 0.98, 1, 0.47, 0.99, 1, 0.36, 0.96, 1, 0.47, 1, 1, 0.4, 0.99, 1, 0.46,
1, 1, 0.4, 0.99, 1
)
)

情节:

require(ggplot2)
require(grid)
pl1 <- ggplot(data=df_nSubj,aes(x=nSubj,y=pow,group=family))+
geom_point(aes(shape=family))+geom_line()+
labs(x="Number of subjects",y="Power",shape="")+
scale_y_continuous(limits=c(0.2,1),breaks=c(0.2,0.4,0.6,0.8,1))+
guides(shape = guide_legend(ncol = 4))+
facet_grid(Spher~effSize)+
theme_bw()+
theme(legend.position = "top",
panel.margin = unit(2, "lines"),
legend.key = element_blank(),
strip.text.x = element_blank(),
strip.text.y = element_blank(),
strip.background = element_blank(),
panel.border=element_blank(),
axis.line=element_line(),
axis.title.x = element_text(vjust=-0.5))

here's how it looks like

提前致谢

最佳答案

facet_grid(Spher~effSize)更改为facet_wrap(Spher~effSize,scales = "free")

enter image description here

关于r - 显示facet_grid中每个图的x轴和y轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24161073/

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