在ggplot2中,如何将绘图标题放在绘图的底部.
qplot(rnorm(100)) + ggtitle("My Title")
Run Code Online (Sandbox Code Playgroud)
把标题放在情节的中间和顶部,而我希望它位于情节的中间和底部.
rcs*_*rcs 10
这是一个解决方案grid.text:
library("grid")
qplot(rnorm(100)) + theme(plot.margin=unit(c(0.5, 1, 2, 0.5), "lines"))
grid.text("My Title", x = unit(0.5, "npc"), y = unit(0, "npc"),
vjust = -0.5, gp = gpar(cex=1.2))
Run Code Online (Sandbox Code Playgroud)

在开发版本中,您可以使用caption参数,
ggplot() +
labs(caption="Bottom Title") +
theme(plot.caption = element_text(hjust=0.5, size=rel(1.2)))
Run Code Online (Sandbox Code Playgroud)
或者,将图包装在grid.arrange()中,
gridExtra::grid.arrange(ggplot(), bottom="Bottom Title")
Run Code Online (Sandbox Code Playgroud)