Italics in ggplot

I'm having trouble italicizing my title. I've tried a couple different codes, but none seem to register with R. Does anyone have a suggestion based on my code? Thanks in advance.

ggplot(aes(x = year, y = Ratio, group = Category, color = Category), data = Cat_Year) +
  #geom_line() +
  stat_smooth(se=F) +
  theme_bw() +
  ggtitle("Ratio of Posts by Category")+
  ylab("Weight of Category") +
  xlab("Year")
'''

You can change the text properties of the plot title with the theme function. See: Theme and Theme elements

Compare these two plots:

 library(ggplot2)
  Df <- data.frame(X = 1:4, Y = 1:4)
  
  ggplot(Df, aes(X, Y)) + geom_point() +
    labs(title = "My Title") 

  
  ggplot(Df, aes(X, Y)) + geom_point() +
    labs(title = "My Title") +
    theme(plot.title = element_text(face = "italic"))

Created on 2021-02-08 by the reprex package (v0.3.0)

Beautiful. Thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.