How can I add a subtitle and change the font size of ggplot plots in R?

后端 未结 2 409
[愿得一人]
[愿得一人] 2021-02-01 17:18

I tried adding a subtitle using +opts(subtitle=\"text\") but nothing showed up. The main title does work (+opts(title=\"text\")).

I would also

2条回答
  •  执念已碎
    2021-02-01 17:32

    theme_get() will show you the "hidden" options that you can use in opts(), post 0.91 it's theme()

    Current:

    theme(axis.text.x=element_text(size=X))
    theme(axis.text.y=element_text(size=X))
    

    Pre 0.91:

    opts(axis.text.x=theme_text(size=X))
    opts(axis.text.y=theme_text(size=X))
    

    Change size, to your desired size.

    wrt the title, you can use "\n" to move the remaining text to a new line:

    Current:

    labs(title="text \n more text")
    

    Pre 0.91:

    opts(title="text \n more text") 
    

    ggplot2 doesn't have "subtitle" functionality. But you can use the \n term in any of the labels to drop down a line.

提交回复
热议问题