【发布时间】:2021-06-25 09:01:29
【问题描述】:
我有这个 ggplot :plot1
我已使用此代码获得了此图:
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 个图,以使可视化更易于理解。所以我用了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)")+ylim(-1,120)+labs(colour = "Groupe PC1")+theme_minimal()+theme(axis.text.x = element_text(size = 7, angle = 90))
g+facet_grid(haha~.)
我得到了这个情节:
但我想获得 2 个不同的 x 轴,并且我希望我的抖动图不那么集中(不那么紧)。
希望有人能给我解决办法。
提前致谢:)
【问题讨论】:
-
如果您创建一个小的可重现示例以及预期的输出,这将更容易提供帮助。阅读how to give a reproducible example。
-
facet_grid()在单个列中不能有单独的 x 轴。可能facet_wrap()更适合。 -
没有看到数据,我会说当然可以:试试
facet_grid(haha~., scales = "free_y")
标签: r ggplot2 divide facet-wrap facet-grid