Skip to content

fails with ggh4x::facet_wrap2(trim_blank=FALSE) #442

@r2evans

Description

@r2evans

When using ggh4x::facet_wrap2 in a subplot and combining, it works only if trim_blank=TRUE (the default); if I try to preserve blanks then it presents a blank canvas.

library(ggplot2)
library(patchwork)
spldat <- data.frame(x=c(1, 1, 2), y = c(1, 2, 2)) |> split(~ x)
plots <- lapply(spldat, \(dat) ggplot(dat, aes(x, y)) + geom_point() +
                                 ggh4x::facet_wrap2(y ~ ., ncol = 2, trim_blank = TRUE))
Reduce(`/`, plots)
Image
plots <- lapply(spldat, \(dat) ggplot(dat, aes(x, y)) + geom_point() +
                                 ggh4x::facet_wrap2(y ~ ., ncol = 2, trim_blank = FALSE))
Reduce(`/`, plots)

(empty for me)

plots[[1]]
plots[[2]]
Image Image
session info
xfun::session_info("patchwork")
# R version 4.4.3 (2025-02-28)
# Platform: aarch64-apple-darwin20
# Running under: macOS Sequoia 15.5
# Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
# Package version:
#   cli_3.6.5          farver_2.1.2       ggplot2_3.5.2      glue_1.8.0         graphics_4.4.3     grDevices_4.4.3    grid_4.4.3         gtable_0.3.6      
#   isoband_0.2.7      labeling_0.4.3     lattice_0.22.6     lifecycle_1.0.4    magrittr_2.0.3     MASS_7.3.64        Matrix_1.7.2       methods_4.4.3     
#   mgcv_1.9.1         nlme_3.1.167       patchwork_1.3.1    pillar_1.10.2      pkgconfig_2.0.3    R6_2.6.0           RColorBrewer_1.1.3 rlang_1.1.6       
#   scales_1.4.0       splines_4.4.3      stats_4.4.3        tibble_3.3.0       utf8_1.2.4         utils_4.4.3        vctrs_0.6.5        viridisLite_0.4.2 
#   withr_3.0.2       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions