ggpubr icon indicating copy to clipboard operation
ggpubr copied to clipboard

Cannot add subtitle

Open angoodkind opened this issue 5 years ago • 2 comments

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"))

angoodkind avatar Oct 01 '19 01:10 angoodkind

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 avatar Apr 24 '23 19:04 mpage21

@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)")
)

mpage21 avatar Apr 24 '23 20:04 mpage21