R 将ggplot划分为不同的GG2 PLOT

R 将ggplot划分为不同的GG2 PLOT,r,ggplot2,divide,facet-wrap,facet-grid,R,Ggplot2,Divide,Facet Wrap,Facet Grid,我有这样一个情节: 我用这个代码得到了这个图: g<- ggplot(base__, aes(x=Race_name, y=ec_prem, color=nouv_grp))+scale_color_brewer(palette = "Paired")+ geom_jitter(position=position_jitter(0.2))+xlab("Course")+ylab("Ecart / 1er (secondes)&qu

我有这样一个情节:

我用这个代码得到了这个图:

   g<- ggplot(base__, aes(x=Race_name, y=ec_prem, color=nouv_grp))+scale_color_brewer(palette = "Paired")+
  geom_jitter(position=position_jitter(0.2))+xlab("Course")+ylab("Ecart / 1er (secondes)")+ylim(-1,120)+labs(colour = "Groupe PC1")+theme_minimal()+theme(axis.text.x = element_text(size = 7, angle = 90))
g
我得到了这个情节:

但我想得到2个不同的x轴,我想我的抖动曲线图要不那么集中(不那么紧凑)

我希望有人能给我一个解决办法


提前感谢:)

正如teunbrand所提到的,
facet\u grid()
不允许对对齐的轴使用不同的比例(即,列中的x均匀,行中的y均匀),但是
facet\u wrap()
可以帮助您解决这个问题。但是,为了让轴文本为每个方面打印,我认为
lemon::facet\u rep\u wrap()
是您所需要的。下面是一个小例子

库(tidyverse)
图书馆(柠檬)
#> 
#>附加包装:“柠檬”
#>以下对象被“package:purrr”屏蔽:
#> 
#>     %||%
#>以下对象被“package:ggplot2”屏蔽:
#> 
#>坐标笛卡尔,元素渲染
mtcars%>%
行名到列(var=“car\u name”)%>%
ggplot(aes(x=汽车名称,y=英里/加仑))+
geom_col()+
刻面重新包装(
面=变量(圆柱体),
ncol=1,
repeat.tick.labels=TRUE,
scales=“免费”
) +
主题(axis.text.x=元素\文本(
角度=90,
hjust=1,
vjust=0.5
))


由(v1.0.0)于2021-03-29创建。

如果您创建一个小的可复制示例以及预期输出,则会更容易提供帮助。了解。
facet\u grid()
不能在一列中有单独的x轴。也许
facet\u wrap()
更适合这样做。在没有看到数据的情况下,我会说它当然可以:试试
facet\u grid(哈哈,scales=“free\u y”)
谢谢Dan Adams,我想这是我需要的解决方案。在我的数据框中,对应于“car\u name”的变量是“Race\u name”,我得到了这个错误:“Column name
Race\u name
不能重复。”我将尝试看看有什么问题
g=ggplot(base__, aes(x=Race_name, y=ec_prem, color=nouv_grp))+scale_color_brewer(palette = "Paired")+
  geom_jitter(position=position_jitter(0.2))+xlab("Course")+ylab("Ecart / 1er (secondes)")+ylim(-1,120)+labs(colour = "Groupe PC1")+theme_minimal()+theme(axis.text.x = element_text(size = 7, angle = 90))
g+facet_grid(haha~.)