R:ggplot2使用facet_wrap设置中间的最后一个图 [英] R: ggplot2 setting the last plot in the midle with facet_wrap
本文介绍了R:ggplot2使用facet_wrap设置中间的最后一个图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用facet_wrap创建一些多图.但是,我不确定是否适合我的图表.这是一个简短的可复制示例:
I am trying to create some multiplots with facet_wrap. Howeever I am not sure if ist the right approach for my graph. Here is a short reproducible example:
ggplot(airquality, aes(x = Day, y = Temp)) +
facet_wrap(~Month) +
geom_line()
这将在此处生成该图:
是否可以使用facet_wrap方法居中"第二行中的两个图? 请注意,我不想对图进行重新排序,我只想将第二行居中
Is it possible to "center" the two plots in the 2nd row with the facet_wrap approach ? Note, that I dont want to reorder the plots, I just want to Center the 2nd row
推荐答案
@Tjebo关于使用cowplot
的建议将起作用:
@Tjebo's suggestion of using cowplot
will work:
p <- ggplot(mapping = aes(x = Day, y = Temp)) +
facet_wrap(~Month) +
geom_line()
cowplot::plot_grid(
p %+% subset(airquality, Month < 8),
p %+% subset(airquality, Month > 7),
nrow = 2
)
这篇关于R:ggplot2使用facet_wrap设置中间的最后一个图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文