0

In all the examples I have see with ggplot() lab(title="") or ggtitle=("") gives the title center aligned, but I have to add + theme(plot.title = element_text(hjust = .5)) to the code below to center align my title. I have not seen that in the examples i.e. title is automatically center aligned, why is that?

ggplot(c4w4.12, aes( x = as.factor(year), y = value, label = round(value, 2))) + 
  geom_line( aes(y = value, color = variable, group = variable)) + geom_text() + 
  scale_color_discrete(name ="City", 
                       labels =c("Los Angles","Baltimore")) + 
  xlab("Year") + 
  ylab("Emission") + 
  ggtitle("Emissons from motor vehicles")

enter image description here

shiny
  • 3,380
  • 9
  • 42
  • 79
Bhail
  • 385
  • 1
  • 2
  • 18
  • 6
    left-aligned titles are the ggplot2 default as of [version 2.2.0](https://blog.rstudio.org/2016/09/30/ggplot2-2-2-0-coming-soon/). You can set the default back to center for a given session by adding (after loading ggplot2) `theme_set(theme_grey() + theme(plot.title=element_text(hjust=0.5))` at the beginning of an R script or in your Rprofile.site file. – eipi10 Jan 05 '17 at 03:36
  • @eipi10 Thanks. I could copy and paste that to Answers my own question. Is there a way to make your comment the suggested answer. – Bhail Jan 05 '17 at 03:50

0 Answers0