Reputation: 7565
In ggplot2, how to put the plot title at the bottom of the plot.
qplot(rnorm(100)) + ggtitle("My Title")
puts the title at middle and top of plot, while I want it to be at middle and bottom of the plot.
Upvotes: 16
Views: 16743
Reputation: 77096
With the dev version you can use the caption argument,
ggplot() +
labs(caption="Bottom Title") +
theme(plot.caption = element_text(hjust=0.5, size=rel(1.2)))
Alternatively, wrap the plot in grid.arrange(),
gridExtra::grid.arrange(ggplot(), bottom="Bottom Title")
Upvotes: 14
Reputation: 68819
Here is a solution using 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))
Upvotes: 13