Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting theme options with theme_set returns an error with current patchwork #180

picasa opened this issue May 15, 2020 · 2 comments


Copy link

picasa commented May 15, 2020


I can't find traces of this patchwork error online. I do not understand this error but can fix it by setting theme options in individual plots. My initial problem was with plots in list-columns and it took me a while to get to the theme_set option; hence this post :)



p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) 
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) 

p1 + p2
#> Error in x$grobs[[grep(paste0("^", name, "$"), x$layout$name)]]: attempt to select less than one element in get1index
#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> other attached packages:
#> [1] patchwork_1.0.0 ggplot2_3.3.0  
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.4.6     knitr_1.28       magrittr_1.5     tidyselect_1.1.0
#>  [5] munsell_0.5.0    colorspace_1.4-1 R6_2.4.1         rlang_0.4.6     
#>  [9] dplyr_0.8.5      stringr_1.4.0    highr_0.8        tools_4.0.0     
#> [13] grid_4.0.0       gtable_0.3.0     xfun_0.13        withr_2.2.0     
#> [17] htmltools_0.4.0  ellipsis_0.3.0   assertthat_0.2.1 yaml_2.2.1      
#> [21] digest_0.6.25    tibble_3.0.1     lifecycle_0.2.0  crayon_1.3.4    
#> [25] farver_2.0.3     purrr_0.3.4      vctrs_0.3.0      glue_1.4.1      
#> [29] evaluate_0.14    rmarkdown_2.1    labeling_0.3     stringi_1.4.6   
#> [33] compiler_4.0.0   pillar_1.4.4     scales_1.1.1     pkgconfig_2.0.3

Created on 2020-05-15 by the reprex package (v0.3.0)

Copy link

llrs commented May 15, 2020

Hi, I don't understand the solution, which options do you set for each plot?

I tried adding the theme with (p1 + theme_void()) + (p2 + theme_void()) but resulted on the same error message.

Copy link

picasa commented May 15, 2020

Hmmm, yes I did not thought to try your way. I defined theme options at the plot level.


p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + theme_void()
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) + theme_void()

p1 + p2

Created on 2020-05-15 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants