library(grid)
library(gridtext) # devtools::install_github("clauswilke/gridtext")
library(gridExtra)
library(ggplot2)
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point() +
labs(title = "Replace-able") -> gg
gb <- ggplot_build(gg)
gt <- ggplot_gtable(gb)
title <- "<span style='font-size:20'>Iris </span><span style='font-size:12'>[some text]</span>"
tg <- rich_text_grob(title, x = unit(0, "lines"), y = unit(2, "lines"))
gt$grobs[[16]] <- tg
grid.newpage()
grid.draw(gt)
Then, there's:
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point() -> gg
title <- "<span style='font-size:20'>Iris </span><span style='font-size:12'>[some text]</span>"
tg <- rich_text_grob(title, x = unit(2, "lines"), y = unit(2, "lines"))
grid.newpage()
grid.draw(
arrangeGrob(tg, gg, heights=c(0.1, 0.8))
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…