ggplot2: have common facet bar in outer facet panel in 3-way plot

前端 未结 3 492
天命终不由人
天命终不由人 2020-12-11 16:30

I have the following code:

label_rev <- function(labels, multi_line = TRUE, sep = \": \") {
     label_both(rev(labels), multi_line = multi_line, sep = se         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-11 17:00

    This can now easily be done with facet_nested() from the ggh4x package

    library(ggplot2)
    # devtools::install_github("teunbrand/ggh4x")
    library(ggh4x)
    p <- ggplot(data = mtcars, aes(wt, mpg)) + geom_point()
    p + 
      facet_nested(vs + cyl ~ am + gear, labeller = label_both) +
      theme(panel.spacing = unit(0,"line")) 
    

    Created on 2020-03-25 by the reprex package (v0.3.0)

提交回复
热议问题