I would like to put three figures next to each other in a figure. I have been reading the introduction to R, section 12 several times now, and I still can't make heads or tails out of it. Lets say that I have three dataframes a, b, c, and I want to plot a$V1, b$V1 and c$V1 in separate plots simply using plot(), how do I put them next to each other? I am sorry if this is a FAQ, but I cannot understand what it says in the guide and the wonderful google couldn't turn up anything helpful either...:) Karin -- Karin Lagesen, PhD student karin.lagesen at medisin.uio.no http://www.cmbn.no/rognes/
probably you need: par(mfrow = c(1, 3)) plot(a$V1) plot(b$V1) plot(c$V1) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Karin Lagesen" <karin.lagesen at medisin.uio.no> To: <r-help at stat.math.ethz.ch> Sent: Friday, September 23, 2005 2:14 PM Subject: [R] multifigure question> > I would like to put three figures next to each other in > a figure. I have been reading the introduction to R, > section 12 several times now, and I still can't make heads > or tails out of it. > > Lets say that I have three dataframes a, b, c, and I want > to plot a$V1, b$V1 and c$V1 in separate plots simply using > plot(), how do I put them next to each other? > > I am sorry if this is a FAQ, but I cannot understand what > it says in the guide and the wonderful google couldn't > turn up anything helpful either...:) > > Karin > -- > Karin Lagesen, PhD student > karin.lagesen at medisin.uio.no > http://www.cmbn.no/rognes/ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
There are actually several ways to do this in R. You probably want par with mfrow= or mfcol= as has already been mentioned but here are some possibilities: 1. par(mfrow=...) has already been mentioned with an example. 2. par(mfcol=...) is similar. See ?par 3. layout. See ?layout 4. split.screen. See ?split.screen 5. grid.layout using grid graphics. See: http://tolstoy.newcastle.edu.au/R/devel/05/06/1169.html for an example. 6. Some of graphics routines themselves can do this in one call. plot.ts will plot ts class time series in mulitiple plots (unless you specify plot.type = "single". e.g. plot(ts(matrix(1:10,5))) plot.zoo from the zoo package is similar but also has an ncargument for specifying the arrangement: library(zoo) plot(zoo(matrix(1:15,5)), nc = 3) Various lattice routines that support conditioning such as xyplot will automatically plot multiple plots. The layout= argument to xyplot can control this. library(lattice) xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris, layout = c(3,1)) Try help with the various commands above. On 9/23/05, Karin Lagesen <karin.lagesen at medisin.uio.no> wrote:> > I would like to put three figures next to each other in > a figure. I have been reading the introduction to R, > section 12 several times now, and I still can't make heads > or tails out of it. > > Lets say that I have three dataframes a, b, c, and I want > to plot a$V1, b$V1 and c$V1 in separate plots simply using > plot(), how do I put them next to each other? > > I am sorry if this is a FAQ, but I cannot understand what > it says in the guide and the wonderful google couldn't > turn up anything helpful either...:) > > Karin > -- > Karin Lagesen, PhD student > karin.lagesen at medisin.uio.no > http://www.cmbn.no/rognes/ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >