teunbrand / ggh4x

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

geom_rectmargin won't work bug with fill_alpha #152

Closed bmansfeld closed 3 months ago

bmansfeld commented 3 months ago

Hi, I'm trying to get geom_rectmargin() to run but running in to this issue:

> library(tidyverse)
> library(ggh4x)
> df <- data.frame(
+   xmin = c(1, 5),
+   xmax = c(2, 7),
+   ymin = c(1, 2),
+   ymax = c(2, 4),
+   fill = c("A", "B")
+ )
> base <- ggplot(df, aes(xmin = xmin, xmax = xmax,
+                        ymin = ymin, ymax = ymax,
+                        fill = fill)) +
+   geom_rect()
> base
> base + geom_rectmargin()
Error in fill_alpha(data$fill %||% "grey20", data$alpha) : 
  could not find function "fill_alpha"

Hopefully, you can figure that out! Thanks, Ben

SessionInfo:

> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.2     purrr_1.0.2    
 [6] readr_2.1.4     tidyr_1.3.0     tibble_3.2.1    tidyverse_2.0.0 ggh4x_0.2.8    
[11] ggplot2_3.4.3  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11        pillar_1.9.0       compiler_4.2.2     RColorBrewer_1.1-3
 [5] tools_4.2.2        timechange_0.1.1   lifecycle_1.0.3    gtable_0.3.1      
 [9] pkgconfig_2.0.3    rlang_1.1.1        cli_3.6.1          rstudioapi_0.14   
[13] ggrepel_0.9.3      withr_2.5.0        generics_0.1.3     vctrs_0.6.3       
[17] hms_1.1.2          grid_4.2.2         cowplot_1.1.1      tidyselect_1.2.0  
[21] glue_1.6.2         R6_2.5.1           fansi_1.0.3        pheatmap_1.0.12   
[25] farver_2.1.1       tzdb_0.3.0         magrittr_2.0.3     scales_1.2.1      
[29] ellipsis_0.3.2     colorspace_2.0-3   labeling_0.4.2     utf8_1.2.2        
[33] stringi_1.7.8      munsell_0.5.0  
teunbrand commented 3 months ago

Hi Ben, fill_alpha() is a function from ggplot2 3.5.0, so I'd recommend to update ggplot2.

bmansfeld commented 3 months ago

Thanks I'll give it a shot, I read they did a bunch of overhaul. Feel free to close, I'll let you know if it still doesn't work.

Ben

teunbrand commented 3 months ago

Thanks, sounds good to me. Closing this for now then.