Hi, I would like to create a trellis plot (3x2) of 6 individual box plots. It would look like this: (Created semi-manually) <http://r.789695.n4.nabble.com/file/n4647878/Figure8.jpg> What would be the most elegant way to do this? Thank you! -- View this message in context: http://r.789695.n4.nabble.com/create-3x2-panel-boxplots-tp4647878.html Sent from the R help mailing list archive at Nabble.com.
On Tue, Oct 30, 2012 at 3:08 PM, nikalk <nikalk at gmail.com> wrote:> Hi, I would like to create a trellis plot (3x2) of 6 individual box plots. > It would look like this: > (Created semi-manually) > <http://r.789695.n4.nabble.com/file/n4647878/Figure8.jpg> > What would be the most elegant way to do this? > Thank you!Most elegant would be with the lattice or ggplot2 packages, but there's a bit of a learning curve there so perhaps ?layout gets you on your way: Michael
You mention trellis, so I will assume that you already know about the trellis graphics functions (in the lattice package). If you are creating all the plots from a single dataset using conditioning then you can just use the 'layout' argument to specify the 3x2 arrangement (note that this argument does col X row rather than row X col like pretty much everything else). If you are calling the bwplot function 6 times and want to arrange them all on the same page then look at the print.trellis function. On Tue, Oct 30, 2012 at 9:08 AM, nikalk <nikalk at gmail.com> wrote:> Hi, I would like to create a trellis plot (3x2) of 6 individual box plots. > It would look like this: > (Created semi-manually) > <http://r.789695.n4.nabble.com/file/n4647878/Figure8.jpg> > What would be the most elegant way to do this? > Thank you! > > > > -- > View this message in context: http://r.789695.n4.nabble.com/create-3x2-panel-boxplots-tp4647878.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com
I'm not sure it is "the most elegant" way but you can do this with ggplot2 You may have to install it, (install.packages("ggplot2") A very basis example: library(ggplot2) mydata <- data.frame(aa = rep(letters[1:6], each = 11), bb = rep( c("x", "y"), 11), cc <- rnorm(66)) p <- ggplot(mydata , aes( bb, cc ))+ geom_boxplot() + facet_wrap( ~ aa ) p Setting up the overall plot with titles, etc., can take a bit of time and head-pounding, but if you are doing a lot of graphs ggplot2 is a very useful tool to learn. John Kane Kingston ON Canada> -----Original Message----- > From: nikalk at gmail.com > Sent: Tue, 30 Oct 2012 08:08:11 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] create 3x2 panel boxplots > > Hi, I would like to create a trellis plot (3x2) of 6 individual box > plots. > It would look like this: > (Created semi-manually) > <http://r.789695.n4.nabble.com/file/n4647878/Figure8.jpg> > What would be the most elegant way to do this? > Thank you! > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/create-3x2-panel-boxplots-tp4647878.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!