ggplot2画图时标题无法居中的问题

折腾了一天,终于好了。应该是版本的问题。在R3.2.2能居中(别问我为什么知道),在R3.3.2上就不能。解决方式如下:

library(ggplot2)
ggplot(data=mtcars, aes(x=wt, y=mpg)) +
  geom_point() +
  labs(title="Automobile Data", x="Weight", y="Miles Per Gallon")+
  theme(plot.title = element_text(hjust = 0.5))  #也就加上这一行

原文地址:https://www.cnblogs.com/aloiswei/p/6150480.html