YuLab-SMU / aplot

Decorate a plot with associated information
https://yulab-smu.top/aplot
92 stars 14 forks source link

aplot can not run example. #27

Closed shanshenbing closed 1 year ago

shanshenbing commented 1 year ago

When I try to run example codes in https://yulab-smu.top/pkgdocs/aplot.html, I got errors.

library(aplot) no_legend=theme(legend.position='none') d <- group_by(mtcars, cyl) %>% summarize(mean=mean(disp), sd=sd(disp)) d2 <- dplyr::filter(mtcars, cyl != 8) %>% rename(var = cyl)

p1 <- ggplot(d, aes(x=cyl, y=mean)) + geom_col(aes(fill=factor(cyl)), width=1) + no_legend p2 <- ggplot(d2, aes(var, disp)) + geom_jitter(aes(color=factor(var)), width=.5) + no_legend

pp <- list(p1,p2) plot_list(pp, ncol=1)

output errors: Error in UseMethod("as.grob") : no applicable method for 'as.grob' applied to an object of class "list"

r$> sessionInfo() R version 4.2.3 (2023-03-15) Platform: x86_64-conda-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS/LAPACK: /cluster/home/shanshenbing/soft/anaconda3/envs/r/lib/libopenblasp-r0.3.21.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] aplot_0.1.10 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.1 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1
[9] ggplot2_3.4.1 tidyverse_1.3.1

loaded via a namespace (and not attached): [1] pillar_1.9.0 compiler_4.2.3 cellranger_1.1.0 dbplyr_2.3.2 yulab.utils_0.0.6 tools_4.2.3 jsonlite_1.8.4
[8] lubridate_1.9.2 lifecycle_1.0.3 gtable_0.3.3 timechange_0.2.0 pkgconfig_2.0.3 rlang_1.1.0 reprex_2.0.2
[15] ggplotify_0.1.0 rstudioapi_0.14 DBI_1.1.3 cli_3.6.1 patchwork_1.1.2 haven_2.5.2 xml2_1.3.3
[22] withr_2.5.0 httr_1.4.5 gridGraphics_0.5-1 generics_0.1.3 vctrs_0.6.1 fs_1.6.1 hms_1.1.3
[29] grid_4.2.3 tidyselect_1.2.0 glue_1.6.2 R6_2.5.1 fansi_1.0.4 readxl_1.4.2 farver_2.1.1
[36] tzdb_0.3.0 modelr_0.1.11 magrittr_2.0.3 backports_1.4.1 scales_1.2.1 rvest_1.0.3 colorspace_2.1-0
[43] labeling_0.4.2 utf8_1.2.3 stringi_1.7.12 munsell_0.5.0 broom_1.0.4 ggfun_0.0.9 crayon_1.5.2

GuangchuangYu commented 1 year ago
plot_list(gglist=pp, ncol=1)

or

plot_list(p1, p2, ncol=1)
shanshenbing commented 1 year ago

Thank you for your fast reply. It works.