【问题标题】:Manually placing facets in facet plot ggplot在 facet plot ggplot 中手动放置 facets
【发布时间】:2023-01-14 00:37:30
【问题描述】:

例如,如果您有 7 个面板并且您指定 facet_wrap(~model, nrow = 3) ggplot 将默认为 3x3x1 布局。是否可以让 ggplot 执行 3x2x2(或 2x2x3 等)?

【问题讨论】:

    标签: r ggplot2 facet facet-wrap


    【解决方案1】:

    您可以使用 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)
    

    【讨论】:

      猜你喜欢
      • 2019-08-04
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      相关资源
      最近更新 更多