Two different ways: library(ggplot2) x=5 size=50 A=data.frame(X=sample(x, size, replace=T), Y=sample(x, size, replace=T),a=rep(1:2,each=25));A # Facetting qplot(X,Y,data=A) + geom_jitter(position=position_jitter(width=.03)) + facet_grid(.~a) # Or with vp p=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.03)) ggsave(p, file='main.png') p1=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.3)) ggsave(p1, file='main2.png') vport <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() pushViewport(viewport(layout=grid.layout(1,2))) print(p, vp=vport(1,1)) print(p1, vp=vport(1,2)) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA
----- Original Message ---- > From: Erik Iverson <er...@ccbr.umn.edu> > To: Peng Yu <pengyu...@gmail.com> > Cc: ggplot2 <ggpl...@googlegroups.com> > Sent: Sun, May 30, 2010 7:45:22 PM > Subject: Re: Put two plots side by side > > > > I want to put the above two plots side by side (essentially, > to mimic > par(mfrow=c(1,2)) in the traditional graphic system). Is there > a > convenient way to do so in ggplot2? > Yes. My > understanding is that you need to create use grid functions to do this. You > can > create a viewport with a layout (using grid.layout) and then print the > ggplot2 > objects using the vp argument. I don't know if there is a ggplot2 > abstraction for this idea. -- You received this message because you are > subscribed to the ggplot2 mailing list. Please provide a reproducible > example: http://gist.github.com/270442 To post: email > ymailto="mailto:ggpl...@googlegroups.com" > href="mailto:ggpl...@googlegroups.com">ggpl...@googlegroups.com To > unsubscribe: email ggplot2+> > href="mailto:unsubscr...@googlegroups.com">unsubscr...@googlegroups.com More > options: http://groups.google.com/group/ggplot2 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.