16
如果我有一个标题,进入[R GGPLOT2中心对齐多行标题
... +
ggtitle('Something\nSomething Else\nSomething Else')
有没有什么办法可以让每一行居中对齐,而不是左对齐的中心?
...+
theme(plot.title=element_text(hjust=0.5))
给我中间的文字,但左对齐。
如果我有一个标题,进入[R GGPLOT2中心对齐多行标题
... +
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))
有关的情节标题错别字对不起...
嗨@EricFail感谢的作品。我没有注意到,但我的问题更具体。看来只有当我使用'ggtitle(表达式(italic(somthing \ nsomething)))'时才会出现问题''但那不是我所问的。感谢您的回答。 – 2013-04-18 07:16:17
plotmath和多行不混合,这就是为什么你的表达问题。 – baptiste 2013-05-13 22:45:16
有关详细信息,可以查看此[文章](http://www.cookbook-r.com/Graphs/Titles_(ggplot2)/) – 2016-05-09 12:54:52