Plot title at bottom of plot using ggplot2

前端 未结 2 1390
野性不改
野性不改 2020-12-07 01:19

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

2条回答
  •  生来不讨喜
    2020-12-07 01:51

    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))
    

    plot

提交回复
热议问题