如果我的标题是
... +
ggtitle('Something\nSomething Else\nSomething Else')
是否有办法让每一行都居中对齐而不是在中心左侧对齐?
...+
theme(plot.title=element_text(hjust=0.5))
将文本居中,但是左对齐。
这对你有用吗,
# install.packages("ggplot2", dependencies = TRUE)
require(ggplot2)
DF <- data.frame(x = rnorm(400))
m <- ggplot(DF, aes(x = x)) + geom_histogram()
m + labs(title = "Vehicle \n Weight-Gas \n Mileage Relationship \n
and some really long so that you can seee it's centered") +
theme(plot.title = element_text(hjust = 0.5))
抱歉剧情标题中的拼写错误...
ggtitle(expression(italic(somthing\nsomething else)))
时才会出现问题,但这不是我问的问题。感谢您的回答。 - Tahnoon Pasha