2x2网格中的三个ggplots [英] Three ggplots in a 2x2 grid

查看:36
本文介绍了2x2网格中的三个ggplots的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为3个ggplot对象设置(使用 par(mfrow =())或其他方式)多个绘图面板,其中一个占整个行,而另两个放置在第二行行吗?

Is it possible to set (with par(mfrow=()) or something else) a multiple plot panel for 3 ggplot objects, where one takes whole row and the other two are placed in second row?

推荐答案

是的,您可以使用gridExtra的rangingGrob/grid.arrange进行此操作.请参见此处为此,您可以这样做

Yes you can do this using arrangeGrob / grid.arrange from gridExtra. See here To do this for your example, you'd do

library(ggplot2)
library(gridExtra)
g1 <- qplot(rnorm(10), rnorm(10))
g2 <- qplot(rpois(100, 10), geom = "histogram")
g3 <- qplot(rnorm(10))
my_plots <- list(g1, g2, g3)
my_layout <- rbind(c(1, 1), c(2, 3))
grid.arrange(grobs = my_plots, layout_matrix = my_layout)

这篇关于2x2网格中的三个ggplots的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆