[R] several plots on several pages

Rainer M. Krug Rainer at krugs.de
Thu Aug 16 14:57:43 CEST 2007


Hi

 > version
                _
platform       i686-pc-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status
major          2
minor          5.1
year           2007
month          06
day            27
svn rev        42083
language       R
version.string R version 2.5.1 (2007-06-27)



I want to create a pdf withe three graphs on a page and with two pages:

-------------
|     1     |
-------------
|     2     |
-------------
|     3     |
-------------

NEW PAGE

-------------
|     4     |
-------------
|     5     |
-------------
|     6     |
-------------

Graph 1 should ALWAYS be at that spot, graph two also, even if graph one 
produces an error when plotting (the area can be empty, but doesn't have 
to.)

I produced the foolowing code below, but I have a few problems:

1) how can I create a new page in the pdf?

2) how can I make sure that the second graph is in position 2 when graph 
one produces an error when plotting I(as in the example)? Everything 
works OK (for the firsat page) when graph one is plotted.

I have the feeling, that I am thinking to complicated.

Any help welcome,

Rainer


pdf("test.pdf")
try(
     {
     ## Set layout to three rows and only oine column
     par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

     ## First row
     par(mfg=c(1,1))
     try( plot(runif(ff)) )

     ## Second row
     par(mfg=c(2,1))
     try( plot(runif(100)) )

     ## Third row
     par(mfg=c(3,1))
     plot(runif(1000))


     ## THE NEXT THREE SHOULD BE ON A NEW PAGE IN THE PDF

     ## Set layout to three rows and only oine column
     par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

     ## First row
     par(mfg=c(1,1))
     try( plot(runif(ff)) )

     ## Second row
     par(mfg=c(2,1))
     try( plot(runif(100)) )

     ## Third row
     par(mfg=c(3,1))
     plot(runif(1000))

     }
     )
dev.off()


-- 
NEW EMAIL ADDRESS AND ADDRESS:

Rainer.Krug at uct.ac.za

RKrug at sun.ac.za WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Tel:		+27 - (0)21 650 5776 (w)
Fax:		+27 - (0)86 516 2782
Fax:		+27 - (0)21 650 2440 (w)
Cell:		+27 - (0)83 9479 042

Skype:		RMkrug

email:	Rainer.Krug at uct.ac.za
       	Rainer at krugs.de



More information about the R-help mailing list