Kia Ora everybody. There must be an obvious answer to this, but I can't see it.... I want four square plots in one postscript file. The canonical answer would be: postscript(file="~/f.ps",width=5,height=5) par(pty="s",mfrow=c(2,2)) plot(1:19,xlab="") plot(1:19,xlab="") plot(1:19,xlab="") plot(1:19,xlab="") dev.off() But this isn't quite what I want because there is too much space between the individual plots. The problem does not occur in quite the same way on the X11() device (why is there a difference?) What is the best way to control this aspect of the plot if I want postscript output? -- Robin Hankin, Lecturer, School of Geography and Environmental Science Tamaki Campus Private Bag 92019 Auckland New Zealand r.hankin at auckland.ac.nz tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042
On Fri, 7 Mar 2003, Robin Hankin wrote:> Kia Ora everybody. > > There must be an obvious answer to this, but I can't see it.... > > I want four square plots in one postscript file. The canonical answer > would be: > > postscript(file="~/f.ps",width=5,height=5) > par(pty="s",mfrow=c(2,2)) > plot(1:19,xlab="") > plot(1:19,xlab="") > plot(1:19,xlab="") > plot(1:19,xlab="") > dev.off() > > But this isn't quite what I want because there is too much space > between the individual plots. The problem does not occur in quite the > same way on the X11() device (why is there a difference?)Font size. For 4 plots on 5" x 5" (or even for 1) you want to reduce the pointsize, which is designed for A4 paper.> What is the best way to control this aspect of the plot if I want > postscript output?More generally, par(mar)/par(mai). Note that this defaults to rows, and hence gives marginal space proportional to the pointsize. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
You may try something like this: postscript(file="fig.ps",height=4,width=4) layout(matrix(c(0,1,2,0,3,4),2,3,byrow=TRUE),c(0,1,1),c(1,1)) par(mar=c(5,5,2,2)+.1,mex=.6) The default spacings are different for 2x3 and 2x2. The layout facility allows one to cheat it out. Good luck. Chong Gu> Kia Ora everybody. > > There must be an obvious answer to this, but I can't see it.... > > I want four square plots in one postscript file. The canonical answer > would be: > > postscript(file="~/f.ps",width=5,height=5) > par(pty="s",mfrow=c(2,2)) > plot(1:19,xlab="") > plot(1:19,xlab="") > plot(1:19,xlab="") > plot(1:19,xlab="") > dev.off() > > But this isn't quite what I want because there is too much space > between the individual plots. The problem does not occur in quite the > same way on the X11() device (why is there a difference?) > > What is the best way to control this aspect of the plot if I want > postscript output? > > > > > > > > -- > > Robin Hankin, Lecturer, > School of Geography and Environmental Science > Tamaki Campus > Private Bag 92019 Auckland > New Zealand > > r.hankin at auckland.ac.nz > tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Many thanks to everyone who helped me with resizing my subplots. The problem was that setting par(mfrow=c(2,2)) does not rescale the fonts, which are set to be the right size for A4 paper. What I didn't realize was that resizing the fonts also resizes the positions of axis labels and titles, making the plots look much better. par(mar) can also be changed from its default (A4) values. To my eye, the optimum plots resulted from: postscript(file="fig.ps",height=4,width=4) layout(matrix(c(0,1,2,0,3,4),2,3,byrow=TRUE),c(0,1,1),c(1,1)) par(mar=c(5,5,2,2)+.1,mex=0.5) plot(1:10);plot(1:10);plot(1:10);plot(1:10) dev.off() Could this example (or one like it) be added to the docs for par() ? [there is something similar---but more complicated---in ?layout]. -- Robin Hankin, Lecturer, School of Geography and Environmental Science Tamaki Campus Private Bag 92019 Auckland New Zealand r.hankin at auckland.ac.nz tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042