0
votes

I need to plot multiple plots on a page. I'd like to have a letter on the top left of each plot (e.g. A or B etc). How would I do this with ggplot2?

It's not mentioned in the ggplot2 manual (Hadley Wickham) neither can I find it by searching web indices.

Here's some code that you can use for the illustration.

library( ggplot2 )
p1 <- qplot( rnorm( 10 ), rnorm( 10 ) )
p2 <- qplot( rnorm( 10 ), rnorm( 10 ) )
grid.arrange( p1, p2, nrow=1 )
2
p1 + ggtitle("plot A") + theme(title=element_text(hjust=0)) - baptiste
Thanks for your suggestions. I'm trying to get something that looks like this: (dpc.uba.uva.nl/c/ctz/images/vol81/nr02/8102a03fig4.jpg). Each plot is numbered a-d. It's the a-d's I'm after. - polarise

2 Answers

1
votes

I would suggest putting all your data in one data frame and including a variable with factors 'a', 'b', etc. and then use faceting. So e.g. like this:

require('ggplot2')
df <- data.frame(cbind(rnorm(20),rnorm(20),c('A','B','C','X')))
ggplot(df, aes(x=X1,y=X2)) + geom_point() + facet_wrap(~ X3, ncol=2)

Never mind the ugly labelling, but I think it does what you're looking for!

0
votes

Using Cowplot may solve this problem.

plot_grid(p,q,labels=c('1','2'))

p and q are ggplot object.