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")