[R] layout() and postscript()
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon Jun 17 17:40:39 CEST 2002
Hi Nolwenn,
Yes it is possible to create a postscript file with multiple graphs in
it. Exactly how you go about doing this depends on your meaning of
multiple graphs. If you mean a single "page" with say 4 sub plots on
it, then you can create an eps file as follows:
postscript(file="filename.eps", width=6, height=6, horizontal=FALSE,
onefile=FALSE, pointsize=10)
oldpar <- par(mfrow=c(2,2)) #2 by 2 display filled by rows, plus other
par() settings as required
#do your plotting commands
par(oldpar) #reset par()
dev.off() #close the postscript device and create the eps file.
If you mean a file with many pages, each page being a diagram, then the
syntax is almost the same:
postscript(file="filename.ps", width=6, height=6, horizontal=FALSE,
pointsize=10) #no onefile
#oldpar <- par(some settings) if required
#do your plotting commands/loop
#par(oldpar) if you need to reset
dev.off()
This will create a postscript document with pages of your separate
graphs.
I've been using both recently, the latter to do lots of analyses and
print out the many small results plots, then the former to produce eps
figures that I can include in my documents of the plots that are
interesting.
The layout() and split.screen() functions allow greater control over the
plotting device. If all you need is to split the plotting region into
equal sized areas then the par(mfrow=c(2,2)) type command is the easiest
way to do it (this splits it into a 2 by 2 device) see ?par for
instructions. If you need more control over the sizing of individual
regions or placement of plots then try ?layout or ?split.screen for
help. The example for layout was very helpful when I had to do this
recently.
All the best,
Gavin Simpson
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5402
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch] On Behalf Of Nolwenn Le Meur
Sent: 17 June 2002 15:21
To: r-help
Subject: [R] layout() and postscript()
HI,
I would like to know if it's possible to create a postscript file with
multiple graphs . I'm creating some graphs by the means of a loop and I
want
to save each graph in the same file (splitting making the device by the
number of graphs).
Do I have to use the par(matrix()) option, the layout() function or the
split.screen() one ?
Thanks
Nolwenn
*------------------------------------------*
Nolwenn Le Meur
INSERM U533
Faculté de Médecine
1, rue Gaston Veil
44035 Nantes cedex 1
tél: +33(0)2-40-41-29-86
fax: +33(0)2-40-41-29-50
e-mail: nolwenn.lemeur at nantes.inserm.fr
*------------------------------------------*
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list