[R] Compact presentation of multiple figures
Dear r-helpers, I have six panels: op(par(mfrow = c(2, 3), xaxt = 'n', yaxt = 'n', pty = 's'). Each of them has a variable main = 'i', and xlab = '', ylab = '' I would like to achieve two things: (1) a common x-axis label under panel 5, and one label to the left of panels 1 and 4 (2) minimal space between the panels. I have looked for examples, and even the thorough Les paramètres graphiques didn't help me: I haven't been able to reduce the space between the rows of panels nearly enough. My best attempt: par(pty = 's', xaxt = 'n', yaxt = 'n', mfrow = c(2, 3), mgp = c(1, 0, 0), mar = c(1.1, 2.1, 1.1, 0.1)) _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compact presentation of multiple figures
This will get you started x - rnorm(20) y - rnorm(20) par(pty = 's', xaxt = 'n', yaxt = 'n', mfrow = c(2, 3), mgp= c(1, 0, 0), mar = c(1.1, 2.1, 1.1, 0.1)) plot(y ~ x, main=1, xlab=, ylab=y1) plot(y ~ x, main=2, xlab=, ylab=) plot(y ~ x, main=3, xlab=, ylab=) plot(y ~ x, main=4, xlab=, ylab=y4) plot(y ~ x, main=5, xlab=, ylab=, xaxt=s) plot(y ~ x, main=6, xlab=, ylab=) __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compact presentation of multiple figures
Thanks Richard, That is roughly what I did. However, (1) the distance between the rows is still quite large compared to the distance between the columns; (2) (less important) I still have two ylab, one for each row. On Oct 15, 2006, at 5:12 PM, Richard M. Heiberger wrote: This will get you started x - rnorm(20) y - rnorm(20) par(pty = 's', xaxt = 'n', yaxt = 'n', mfrow = c(2, 3), mgp= c(1, 0, 0), mar = c(1.1, 2.1, 1.1, 0.1)) plot(y ~ x, main=1, xlab=, ylab=y1) plot(y ~ x, main=2, xlab=, ylab=) plot(y ~ x, main=3, xlab=, ylab=) plot(y ~ x, main=4, xlab=, ylab=y4) plot(y ~ x, main=5, xlab=, ylab=, xaxt=s) plot(y ~ x, main=6, xlab=, ylab=) _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compact presentation of multiple figures
I would do something like this in lattice. It defaults to something prettier and gives more control if you don't want the defaults. tmp - data.frame(x=rnorm(120), y=rnorm(120), a=factor(rep(1:6, 20))) xyplot(y ~ x | a, data=tmp) xyplot(y ~ x | a, data=tmp, aspect=1, layout=c(3,2), scales=list(x=list(alternating=c(0,1,0)), y=list(alternating=FALSE))) Back to regular graphics. I misunderstood your request for a single y label. This comes closer. I used oma to squeeeze the two rows closer together. I used two axis(1) statements. The first puts the ticks on the border of the box. The second one puts the labels far enough away that they aren't cluttered. Similar adjustment is called for on the main title of each panel. x - rnorm(20) y - rnorm(20) old.par - par(pty = 's', xaxt = 'n', yaxt = 'n', mfrow = c(2, 3), mar = c(1.1, 2.1, 1.1, 0.1), oma=c(12,2,0,2)) plot(y ~ x, main=1, xlab=, ylab=) plot(y ~ x, main=2, xlab=, ylab=) plot(y ~ x, main=3, xlab=, ylab=) plot(y ~ x, main=4, xlab=, ylab=) mtext(Y label, side=2, at=2, line=2) plot(y ~ x, main=5, xlab=, ylab=) axis(1, xaxt=s, labels=FALSE) axis(1, xaxt=s, tick=FALSE, line=1) plot(y ~ x, main=6, xlab=, ylab=) par(old.par) __ R-help@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 and provide commented, minimal, self-contained, reproducible code.