0

My question is similar to the following post, the only thing I need is to place the titles of each subplot below each figure instead of on the top.

Place title of multiplot panel with ggplot2

Suggestion from baptiste working fine but, I have just two figures and I want them side by side.

p = qplot(1,1) 
lp = list(p,p)
ll = list("sub 1", "sub 2")
plotlist <- mapply(arrangeGrob, lp, sub=ll, SIMPLIFY=FALSE)
do.call(grid.arrange, plotlist)

Thanks

Community
  • 1
  • 1
learner
  • 2,582
  • 9
  • 43
  • 54

1 Answers1

4
library(gridExtra)

p = qplot(1, 1)
grid.arrange(p, p, p, p, sub = textGrob("TITLE BELOW", gp=gpar(cex=2)))

sub

ggplot2 does not have a "sub" parameter, so we wrap each plot in a gTree using arrangeGrob, combining the plot with a text label below. Finally, arrange the composite grobs on the page.

lp = list(p, p, p, p)
ll = list("sub 1", "sub 2", "sub 3", "sub 4")

plotlist <- mapply(arrangeGrob, lp, sub=ll, SIMPLIFY=FALSE)
do.call(grid.arrange, plotlist)

sub2

baptiste
  • 75,767
  • 19
  • 198
  • 294
  • My code is given below: I need the figure side-by-side not one below the other. lp = list(g1,g2) ll = list("sub 1", "sub 2") plotlist <- mapply(arrangeGrob, lp, sub=ll, SIMPLIFY=FALSE) do.call(grid.arrange, plotlist) – learner Jan 21 '12 at 22:49
  • *please* provide a reproducible example and a clear description of your question – baptiste Jan 21 '12 at 23:31