Side-by-side plots with ggplot2 in R

Posted by chris_dubois on Stack Overflow See other posts from Stack Overflow or by chris_dubois
Published on 2009-08-08T18:16:43Z Indexed on 2010/04/28 4:53 UTC
Read the original article Hit count: 244

Filed under:
|
|

I would like to place two plots side by side using the ggplot2 package (ie. do the equivalent of par(mfrow=c(1,2))). For example, I would like to have the following two plots show side-by-side with the same scale.

x <- rnorm(100)
eps <- rnorm(100,0,.2)
qplot(x,3*x+eps)
qplot(x,2*x+eps)

Do I need to put them in the same data.frame like in this example?

qplot(displ, hwy, data=mpg, facets = . ~ year) + geom_smooth()

Thanks!

© Stack Overflow or respective owner

Related posts about r

    Related posts about visualization