设置多面图中的列(或行)数 [英] Set number of columns (or rows) in a facetted plot

查看:50
本文介绍了设置多面图中的列(或行)数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多面的情节,像这样:

I have a facetted plot like this:

ggplot(mtcars, aes(x = hp, y = mpg)) +
  geom_point() +
  facet_grid(. ~ carb)

但是,该图太宽而无法清晰阅读.

However, the graph is too wide to be clearly read.

我希望能够将最右边的三个位置放置在最左边的三个位置下,即,小平面应位于三列*这样的两行中.

I'd like to be able to take the three rightmost locations and place them under the three leftmost, i.e. the facets should be in three columns * two rows like this.

1   2   3

4   5   6

是否可以设置构面的布局,即使用facet_grid()设置列(或行)的数量?

Is it possible to set the layout of the facets, i.e. to set number of columns (or rows) with facet_grid()?

facet_grid 上的文档似乎并不表明这是可能的.

The documentation on facet_grid doesn't seem to indicate that it's possible.

感谢您的帮助:-)

推荐答案

您可以在facet_wrap中使用ncol(或nrow)自变量:

You can use the ncol (or nrow) argument in facet_wrap:

ggplot(mtcars, aes(x = hp, y = mpg)) +
 geom_point()  +
 facet_wrap(~ carb, ncol = 3)

这篇关于设置多面图中的列(或行)数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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