Put row and column titles using grid.arrange in R

Viewed 5010

The data for the ggplots:

set.seed(0)

library(ggplot2)
library(gridExtra)

c <- list()

for (k in 1:9) c[[k]] <- ggplot(data.frame(x=1:10,y=rnorm(10)),aes(x=x,y=y))+geom_line()

grid.arrange (c[[1]],c[[2]],c[[3]],c[[4]],c[[5]]
,c[[6]],c[[7]],c[[8]],c[[9]],ncol=3, nrow=3, widths = c(4,4,4) ,heights = c(4,4,4))

I want titles for each row and each column.

The shape of the output would be something like this:

          CTitle 1 CTitle 2 CTitle 3
RTitle1   plot1     plot2   plot3
RTitle2   plot4     plot5   plot6
RTitle3   plot7     plot8   plot9
2 Answers
Related