I am trying to use ggplot to add a subtitle. Similar question was asked here: How to add a ggplot2 subtitle with different size and colour?, and the answer was as follows:
p <- p + ggtitle(expression(atop(paste('TITLE'), atop(italic(paste('SUBTITLE')), ""))))
However, the words 'TITLE'
and 'SUBTITLE'
need to be hardcoded, presenting an scalability and automation problem when dealing with 1000s of plots.
This does not work:
plot.title = 'TITLE'
plot.subtitle = 'SUBTITLE'
p <- p + ggtitle(expression(atop(paste(plot.title), atop(italic(paste(plot.subtitle)), ""))))
I guess the question on how to proper add dynamic subtitles, using this idea, boils down to: Is it possible to use character variables inside expression and atop?