[R] multifigure question

Gabor Grothendieck ggrothendieck at gmail.com
Fri Sep 23 14:51:16 CEST 2005


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 nc=
argument 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
>




More information about the R-help mailing list