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))  #也就加上这一行

 

posted @ 2016-12-09 17:35  AloisWei  阅读(25523)  评论(0编辑  收藏  举报