rggplot2

How to increase the font size of ggtitle in ggplot2


I would like to increase the font size of ggtitle and also the font should be bold. My code is as follows.

ggplot(df, aes(x1, y = value, colour = variable)) + 
  geom_point(size=2) + 
  ggtitle("male vs.female") +
  theme(axis.text=element_text(size=14),
        axis.title=element_text(size=14,face="bold")) + 
  theme(legend.text=element_text(size=12)) + 
  labs(x = "x axis", y = "y axis") + 
  ylim(0,100) + xlim(0,100) + 
  scale_colour_manual(values = c("red", "blue"), 
                      labels = c("male", "female"))

Solution

  • Use theme(), here is an example :

    ggplot(cars, aes(x=speed,y=dist)) + 
        ggtitle("cars") + geom_point() + 
        theme(plot.title = element_text(size = 40, face = "bold"))
    

    enter image description here

    Inspired by this answer.