teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
534 stars 32 forks source link

Error in x[[idx_w]] : no such index at level 2 #109

Closed tungttnguyen closed 1 year ago

tungttnguyen commented 1 year ago

I think the recent commits of ggplot2 broke ggh4x. This example used to work. Can you confirm? Thanks!

library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.4.2.9000'
library(ggtext)
library(ggh4x)
packageVersion("ggh4x")
#> [1] '0.2.4'

car_class <- sort(unique(mpg$class))
strip_color <- ifelse(car_class == "pickup", "darkred", "darkblue")

strip_background <- strip_themed(
  text_x = elem_list_text(colour = "white", face = 'bold'),
  background_x = elem_list_rect(fill = strip_color)
)

ggplot(mpg, aes(cty, hwy)) + 
  geom_point() +
  facet_wrap2(~ class, strip = strip_background) +
  theme_bw(base_size = 12)
#> Error in x[[idx_w]]: no such index at level 2

Created on 2023-04-24 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.0 (2023-04-21 ucrt) #> os Windows 10 x64 (build 19044) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.utf8 #> ctype English_United States.utf8 #> tz America/Los_Angeles #> date 2023-04-24 #> pandoc 2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) #> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0) #> digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.0) #> dplyr 1.1.2 2023-04-20 [1] CRAN (R 4.3.0) #> evaluate 0.20 2023-01-17 [1] CRAN (R 4.3.0) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.0) #> farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) #> fs 1.6.1 2023-02-06 [1] CRAN (R 4.3.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0) #> ggh4x * 0.2.4 2023-04-04 [1] CRAN (R 4.3.0) #> ggplot2 * 3.4.2.9000 2023-04-25 [1] Github (tidyverse/ggplot2@f6e87ac) #> ggtext * 0.1.2 2022-09-16 [1] CRAN (R 4.3.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) #> gridtext 0.1.5 2022-09-16 [1] CRAN (R 4.3.0) #> gtable 0.3.3 2023-03-21 [1] CRAN (R 4.3.0) #> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.3.0) #> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.3.0) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) #> Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.3.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.3.0) #> rlang 1.1.0 2023-03-14 [1] CRAN (R 4.3.0) #> rmarkdown 2.21 2023-03-26 [1] CRAN (R 4.3.0) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0) #> scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.0) #> vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.3.0) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.3.0) #> xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0) #> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.3.0) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0) #> #> #> ────────────────────────────────────────────────────────────────────────────── ```
teunbrand commented 1 year ago

Indeed it did, see also https://github.com/teunbrand/ggh4x/issues/108#issuecomment-1521263089.

tungttnguyen commented 1 year ago

Thanks @teunbrand

teunbrand commented 1 year ago

I'm closing this issue in favor of #112.