简体   繁体   English

在 facet plot ggplot 中手动放置 facets

[英]Manually placing facets in facet plot ggplot

If, for example, you have 7 panels and you specify facet_wrap(~model, nrow = 3) ggplot will default to a 3x3x1 layout.例如,如果您有 7 个面板并指定facet_wrap(~model, nrow = 3) ggplot 将默认为 3x3x1 布局。 Is it possible to get ggplot to do 3x2x2 (or 2x2x3, etc.)?是否可以让 ggplot 执行 3x2x2(或 2x2x3 等)?

You can use ggh4x to specify the design of your facet:您可以使用ggh4x来指定您的构面design

library(ggh4x)
design = matrix(c(1, 1, 2, 2, 3, 3, 
                  4, 4, 4, 5, 5, 5, 
                  6, 6, 6, 7, 7, 7), 
                3, 6, byrow = TRUE)
ggplot(mpg, aes(displ, hwy, colour = as.factor(cyl))) + 
  geom_point() +
  facet_manual(vars(class), design = design)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM