[R] Unexpected mfrow, layout behavior (pdf still has multiple pages)

Paul Johnston pcj127 at gmail.com
Thu Feb 5 13:23:40 CET 2009

My goal is to create a graph with one column and three rows into a
single graphic. The mfrow, mfcol, and layout functions all have the
same effect: three graphs are produced in a single pdf file, having
one graph per page.  This is not what I want (I didn't want multiple
pages).  Just before I sent this post, I was able to generate the
desired output with split.screen.  Is this the expected behavior of
mfrow and layout?



My code is as follows (ToruosityPlot and DiameterPlot are essentially
identical to LDRPlot).

layout(matrix(1:3, ncol=1))

pdf("results.pdf", width=4, height=3, pointsize=4, colormodel="cmyk",

TortuosityPlot(left, right)
DiameterPlot(left, right)
LDRPlot(left, right)


LDRPlot <- function(left, right)
    plot(left$x, left$LDR, bty="n", ann=FALSE, xlim=c(-1500, 1000),
ylim=c(1.0, 1.5))
    abline(v=0, col=gray(.90))
    lines(left$x, left$LDR, col="green4", lty="solid")
    points(left$x, left$LDR, bg="limegreen", pch=21)
    lines(right$x, right$LDR, col="blue4", lty="dashed")
    points(right$x, right$LDR, bg="blue", pch=21)
    #title(main="LDR", xlab="Distance (um)", ylab="LDR",
col.main="black", col.lab=gray(.4), cex.main=1.2, cex.lab=1.0,
font.main=4, font.lab=3)

platform       i386-apple-darwin8.11.1
arch           i386
os             darwin8.11.1
system         i386, darwin8.11.1
major          2
minor          8.1
year           2008
month          12
day            22
svn rev        47281
language       R
version.string R version 2.8.1 (2008-12-22)

More information about the R-help mailing list