折騰了一天,終於好了。應該是版本的問題。在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)) #也就加上這一行