-
Notifications
You must be signed in to change notification settings - Fork 168
Closed
Description
The issue arose when I wanted to make arrange plots where I had removed the facet strip completely. I isolated the problem down to the removal of the strip.text.
As an example
facet_with_labels <- function(df) {
ggplot(df, aes(hp, mpg)) +
facet_wrap(gear~., ncol=1) + geom_point() }
facet_no_strip_bg <- function(df) {
ggplot(df, aes(hp, mpg)) +
facet_wrap(gear~., ncol=1) + geom_point() + theme(strip.background = element_blank())}
facet_no_striptext <- function(df) {
ggplot(df, aes(hp, mpg)) +
facet_wrap(gear~., ncol=1) + geom_point() + theme(strip.text = element_blank())}
p_with = facet_with_labels(mtcars)
p_no_bg = facet_no_strip_bg(mtcars)
p_no_striptext = facet_no_striptext(mtcars)
All individual plots are OK:
p_with
p_no_bg
p_no_striptext
Combined plot, one with blank facet strip background is OK
p_with + p_no_bg
Combined plot, one with blank facet strip text fails
p_with + p_no_striptext
Error in unit(height, default.units) :
'x' and 'units' must have length > 0
Combined plot, both without strips (my use case)
p_no_striptext + p_no_striptext
Error in unit(height, default.units) :
'x' and 'units' must have length > 0
What I wanted:
cowplot::plot_grid(p_no_striptext, p_no_striptext)
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 19.10
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] patchwork_1.0.1 ggplot2_3.3.1
loaded via a namespace (and not attached):
[1] digest_0.6.25 withr_2.2.0 dplyr_1.0.0 crayon_1.3.4
[5] grid_3.6.1 R6_2.4.1 lifecycle_0.2.0 gtable_0.3.0
[9] magrittr_1.5 scales_1.1.1 pillar_1.4.4 rlang_0.4.6
[13] farver_2.0.3 generics_0.0.2 vctrs_0.3.1 ellipsis_0.3.1
[17] labeling_0.3 glue_1.4.1 purrr_0.3.4 munsell_0.5.0
[21] compiler_3.6.1 pkgconfig_2.0.3 colorspace_1.4-1 tidyselect_1.1.0
[25] tibble_3.0.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

