kassambara / ggpubr

'ggplot2' Based Publication Ready Plots
https://rpkgs.datanovia.com/ggpubr/
1.13k stars 165 forks source link

Cannot add subtitle #211

Open angoodkind opened 5 years ago

angoodkind commented 5 years ago

I am trying to use a common title and subtitle for my plots. How can I add a line below the title, that is also in a different font?

Here is a MWE of what I'm doing:

library(tidyverse)
library(ggpubr)

df <- data.frame()
plot1 <- ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)
plot2 <- ggplot(df) + geom_point() + xlim(0, 10) + ylim(0, 100)

all.plots <- ggarrange(plot1, plot2)
annotate_figure(all.plots,
                top=text_grob("Antibiotic Effectiveness"))
mpage21 commented 1 year ago

I would also like to be able to add a subtitle for the plots. I think this is a good idea that should be implemented.

mpage21 commented 1 year ago

@angoodkind, I know this is years after you needed it, but as a temporary fix, you can use annotate_figure twice to obtain the desired effect. Using the example above

annotate_figure(
        annotate_figure(all.plots,
                top=text_grob("Subtitle"),
        ),
        top=text_grob("Antibiotic Effectiveness (Main title)")
)