Skip to content

Commit 5a065ff

Browse files
Merge pull request #49 from xiangpin/master
fixed tag_levels issue of plot_list when ggplot2 > 3.5.2
2 parents e972bcb + 87637c9 commit 5a065ff

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Imports:
1818
magrittr,
1919
methods,
2020
utils,
21-
yulab.utils (>= 0.1.9)
21+
yulab.utils (>= 0.1.9),
22+
pillar
2223
Suggests:
2324
ggtree
2425
URL: https://github.com/YuLab-SMU/aplot, https://yulab-smu.top/aplot/

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ importFrom(ggplot2,element_text)
4545
importFrom(ggplot2,ggplot)
4646
importFrom(ggplot2,ggplotGrob)
4747
importFrom(ggplot2,ggplot_add)
48+
importFrom(ggplot2,ggplot_build)
4849
importFrom(ggplot2,ggsave)
4950
importFrom(ggplot2,is.ggplot)
5051
importFrom(ggplot2,labs)
@@ -66,4 +67,5 @@ importFrom(patchwork,patchworkGrob)
6667
importFrom(patchwork,plot_annotation)
6768
importFrom(patchwork,plot_layout)
6869
importFrom(patchwork,plot_spacer)
69-
importFrom(utils,modifyList)
70+
importFrom(pillar,style_subtle)
71+
importFrom(utils,packageDescription)

R/plot-list.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
##' @importFrom ggplot2 theme
2323
##' @importFrom ggplot2 element_text
2424
##' @importFrom ggplot2 labs
25-
##' @importFrom utils modifyList
2625
##' @importFrom ggfun ggbreak2ggplot
2726
##' @export
2827
##' @author Guangchuang Yu
@@ -93,7 +92,7 @@ plot_list <- function(..., gglist = NULL,
9392

9493

9594

96-
95+
#' @importFrom ggplot2 ggplot_build
9796
plot_list2 <- function(gglist = NULL,
9897
ncol = NULL,
9998
nrow = NULL,
@@ -117,11 +116,11 @@ plot_list2 <- function(gglist = NULL,
117116
)
118117

119118
if (!is.null(tag_levels) || !is.null(labels)) {
120-
pt <- p$theme$plot.tag
119+
pt <- ggplot_build(p)$plot$theme$plot.tag
121120
if (is.null(pt)){
122121
pt <- ggplot2::element_text()
123122
}
124-
pt <- modifyList(pt, list(size = tag_size))
123+
pt$size <- tag_size
125124
p <- p + plot_annotation(tag_levels=tag_levels) &
126125
theme(plot.tag = pt)
127126
}

R/zzz.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#' @importFrom utils packageDescription
2+
#' @importFrom pillar style_subtle
3+
.onAttach <- function(libname, pkgname) {
4+
pkgVersion <- packageDescription(pkgname, fields="Version")
5+
msg <- paste0(pkgname, " v", pkgVersion, " ",
6+
"For help: https://github.com/YuLab-SMU/aplot/issues", "\n\n")
7+
8+
citation <- paste0("If you use ", pkgname,
9+
" in published research, please cite the paper:\n\n",
10+
aplot_citations())
11+
12+
packageStartupMessage(paste0(strwrap(pillar::style_subtle(paste0(msg, citation, suppressmsg(pkgname)))), collapse="\n"))
13+
}
14+
15+
aplot_citations <- function(){
16+
paste("Shuangbin Xu, Qianwen Wang, Shaodi Wen, Junrui Li, Nan He, Ming Li, Thomas Hackl, Rui Wang,
17+
Dongqiang Zeng, Shixiang Wang, Shensuo Li, Chunhui Gao, Lang Zhou, Shaoguo Tao, Zijing Xie,
18+
Lin Deng, and Guangchuang Yu.",
19+
"aplot: Simplifying the creation of complex graphs to visualize associations across diverse data types.",
20+
"The Innovation. 2025, 6(9):100958. doi: 10.1016/j.xinn.2025.100958\n\n",
21+
"Export the citation to BibTex by citation('aplot')\n\n"
22+
)
23+
24+
}
25+
26+
suppressmsg <- function(pkgname){
27+
paste0("This message can be suppressed by:\n",
28+
"suppressPackageStartupMessages(library(", pkgname ,"))"
29+
)
30+
}

0 commit comments

Comments
 (0)