Search code examples
rggplot2labelscaleitalic

Italic font in one scale label in ggplot


I want to put one label of x axis with italics font with this code:

  scale_x_discrete(labels = c("factor1", "<i>factor2</i>"))+

But it doesn't work. Do I need to install some package? Is there an alternative way to do so?


Solution

  • I would suggest to overwrite the labels as such:

    scale_x_discrete(labels = c("factor1", "factor2" = expression(italic(factor2))))+