An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130709/16ad8489/attachment.pl>
Same plot size with mfrow()
5 messages · Bert Gunter, Charlie Brown, David Winsemius
It is hard to know what to recommend, as you don't give us any context. If the plots are interrelated in certain ways, lattice and ggplot both provide conditioning plots.Check vignettes and documentation for these packages. For base graphics, ?layout may be what you want. Cheers, Bert On Tue, Jul 9, 2013 at 3:23 PM, Charlie Brown
<charliethebrown77 at gmail.com> wrote:
Hello,
I want to plot similar to the example below. I want to remove the X and Y
axis labels to avoid redundancy, but then want to make the spaces between
plots smaller. When I do this (see below), I end up with plots of
different sizes (I want the plots to be exactly the same dimensions).
Could someone help me with this multiple plot setup, I'm sure this is way
too complicated and simpler code will accomplish my goals. Thanks, Charlie
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(3, 5, 2, 1))
par(mar=c(1, 5, 2, 1)+0.1)
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1")
par(mar=c(1, 1, 2, 1)+0.1)
plot(c(1:100), c(1:100), xaxt="n", yaxt="n")
par(mar=c(5, 5, 1, 1)+0.1)
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2")
par(mar=c(5, 1, 1, 1)+0.1)
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2")
dev.off()
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130709/a4ba29a1/attachment.pl>
On Jul 9, 2013, at 3:23 PM, Charlie Brown wrote:
Hello,
I want to plot similar to the example below. I want to remove the X and Y
axis labels to avoid redundancy, but then want to make the spaces between
plots smaller. When I do this (see below), I end up with plots of
different sizes (I want the plots to be exactly the same dimensions).
Could someone help me with this multiple plot setup, I'm sure this is way
too complicated and simpler code will accomplish my goals. Thanks, Charlie
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(3, 5, 2, 1))
Those omi values aRE TOO LARGE.
par(mar=c(1, 5, 2, 1)+0.1) plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1") par(mar=c(1, 1, 2, 1)+0.1) plot(c(1:100), c(1:100), xaxt="n", yaxt="n") par(mar=c(5, 5, 1, 1)+0.1) plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2") par(mar=c(5, 1, 1, 1)+0.1) plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2") dev.off()
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(2,1,1, 1), pin=c(5,4) ) # attempting to force equal sized plot dimensions
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1")
plot(c(1:100), c(1:100), xaxt="n", yaxt="n", ylab="")
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2")
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2", ylab="")
dev.off()
Closer, but if you wnat control over the axis labeling to avoid the irregular gaps, you need to use the `axis` function.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
David Winsemius Alameda, CA, USA
On Jul 9, 2013, at 5:12 PM, David Winsemius wrote:
On Jul 9, 2013, at 3:23 PM, Charlie Brown wrote:
Hello,
I want to plot similar to the example below. I want to remove the X and Y
axis labels to avoid redundancy, but then want to make the spaces between
plots smaller. When I do this (see below), I end up with plots of
different sizes (I want the plots to be exactly the same dimensions).
Could someone help me with this multiple plot setup, I'm sure this is way
too complicated and simpler code will accomplish my goals. Thanks, Charlie
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(3, 5, 2, 1))
Those omi values aRE TOO LARGE.
par(mar=c(1, 5, 2, 1)+0.1) plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1") par(mar=c(1, 1, 2, 1)+0.1) plot(c(1:100), c(1:100), xaxt="n", yaxt="n") par(mar=c(5, 5, 1, 1)+0.1) plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2") par(mar=c(5, 1, 1, 1)+0.1) plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2") dev.off()
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(2,1,1, 1), pin=c(5,4) ) # attempting to force equal sized plot dimensions
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1")
plot(c(1:100), c(1:100), xaxt="n", yaxt="n", ylab="")
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2")
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2", ylab="")
dev.off()
Another effort, using varying mar parameters.
png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.3, cex.axis=1.3, cex.main=2,
omi=c(.5,.5,.5,.5), mar=c(4,4,0,.2), xpd=TRUE )
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1", xlab="")
plot(c(1:100), c(1:100), xaxt="n", yaxt="n", ylab="",xlab="");par(mar=c(4,4,0,0))
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2");par(mar=c(4,4,0,0))
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2", ylab="")
dev.off()
David Winsemius Alameda, CA, USA