stefanedwards / lemon

🍋 Lemon --- Freshing up your ggplots
https://cran.r-project.org/package=lemon
GNU General Public License v3.0
180 stars 11 forks source link

Idea: Strip text search #6

Open stefanedwards opened 6 years ago

stefanedwards commented 6 years ago

To find a strip (any?) grob with a particular label. Question is, what to return? It is essentially a tree-path to the grob.

stefanedwards commented 6 years ago

Code from a project that searches for 'Overall' and updates the gpar to bold.

# find strip overall and make bold
i <- (grepl('strip', g$layout$name) & !sapply(g$grobs, lemon:::is.zero)) %>% which
j <- which(sapply(g$grobs[i], function(x) x[[1]][[1]]$children[[2]]$children[[1]]$label, simplify=FALSE) == 'Overall')
g$grobs[[i[j]]]$grobs[[1]]$children[[2]]$children[[1]]$gp$fontface <- 'bold' 
g$grobs[[i[j]]]$grobs[[1]]$children[[2]]$children[[1]]$gp$font <- c('bold'=2L)