R: ggplot2, can I set the plot title to wrap around and shrink the text to fit the plot?

前端 未结 3 1896
梦如初夏
梦如初夏 2020-11-30 06:42
library(ggplot2)

my_title = \"This is a really long title of a plot that I want to nicely wrap \\n and fit onto the plot without having to manually add the backslas         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 06:53

    I do not think there is a text wrap option in ggplot2 (I have always just inserted \n manually). You can, however, shrink the size of the title's text by altering your code in the following way:

    title.size<-10
    r + geom_smooth() + opts(title = my_title,plot.title=theme_text(size=title.size))
    

    In fact, you all aspects of text with the theme_text function.

提交回复
热议问题