0

I want to create a title for my chart. I previously used default R plotting and 3 mtext calls to create the title. The reason being 3 parts of the title need to be formatted differently (color, size,...).

How can I achieve that with ggplot2?

Previous I had:

mtext("My",col="#990033",cex=3.5,line=2,adj=0.30, font=14)
mtext("Custom",col='azure4',cex=3.5,line=2,adj=0.51, font=14)
mtext("Title",col='azure4', cex=3.5, line=2,adj=0.65, font=16)

I tried with grid.arrange() but then I can only specific 1 element for "top".

beginner_
  • 7,230
  • 18
  • 70
  • 127
  • 3
    Did you try the first google [hit](http://www.cookbook-r.com/Graphs/Titles_(ggplot2)/) or the [second](http://www.sthda.com/english/wiki/ggplot2-title-main-axis-and-legend-titles)? – Roman May 02 '17 at 08:34
  • For instance: `ggplot(PlantGrowth, aes(x=group, y=weight)) + geom_boxplot() + labs(title = "New plot title", subtitle = "A subtitle") + theme( plot.title = element_text(color="red", size=14, face="bold.italic"), plot.subtitle = element_text(color="blue", size=9, face="bold"))`. but you are right the third section is not that trivial. You can try to set up a function using `gtable`. See [here](http://stackoverflow.com/questions/11724311/how-to-add-a-ggplot2-subtitle-with-different-size-and-colour). – Roman May 02 '17 at 08:53
  • What about [this](http://stackoverflow.com/questions/11976590/multicolor-titles-with-ggplot2-for-r) and [that](http://stackoverflow.com/questions/11724311/how-to-add-a-ggplot2-subtitle-with-different-size-and-colour)? Also [via google](https://www.google.com/search?q=ggplot+title+different+colors)... – lukeA May 02 '17 at 08:56

0 Answers0