dear list, i have a problem using the par function. in one graphic device i want to have two plots so i tried to use par(mfror=c(1,2)). of course it worked out, but the height now is twice the length of the width for each single plot. what i actually wanted is something like par(mfrow=c(2,2)) where only the top (or bottom) two plots are drawn with entire length proportions of 1 to 2 ( height 1, width 2) i want to create a pdf figure and can?t figure out how that might work. (e.g. the height should be 8 cm, the length 16 cm but each plot should have the proportion 1:1(height:width)) thanks for any help. stefan
On Fri, 2006-04-28 at 10:07 +0200, Stefan Semmeling wrote:> dear list, > > i have a problem using the par function. > > in one graphic device i want to have two plots so i tried to use > par(mfror=c(1,2)). > of course it worked out, but the height now is twice the length of the width > for each single plot. > what i actually wanted is something like par(mfrow=c(2,2)) where only the > top (or bottom) > two plots are drawn with entire length proportions of 1 to 2 ( height 1, > width 2) > i want to create a pdf figure and can?t figure out how that might work. > (e.g. the height should be 8 cm, the length 16 cm but each plot should have > the proportion 1:1(height:width)) > > thanks for any help. > > stefanIs this what you mean: Square plots, 1 row, 2 cols, 8 by 16cm cmToInch <- 0.393700787 pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * cmToInch, pointsize = 10, onefile = FALSE) opar <- par(mfrow = c(1,2), pty = "s") plot(rnorm(100), rnorm(100)) plot(rnorm(100), rnorm(100)) par(opar) dev.off() or same aspect ratio: pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * cmToInch, pointsize = 10, onefile = FALSE) opar <- par(mfrow = c(1,2)) plot(rnorm(100), rnorm(100), asp = 1) plot(rnorm(100), rnorm(100), asp = 1) par(opar) dev.off() or both: pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * cmToInch, pointsize = 10, onefile = FALSE) opar <- par(mfrow = c(1,2), pty = "s") plot(rnorm(100), rnorm(100), asp = 1) plot(rnorm(100), rnorm(100), asp = 1) par(opar) dev.off() HTH, G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% * Note new Address, Telephone & Fax numbers from 6th April 2006 * %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson ECRC & ENSIS [t] +44 (0)20 7679 0522 UCL Department of Geography [f] +44 (0)20 7679 0565 Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street [w] http://www.ucl.ac.uk/~ucfagls/cv/ London, UK. [w] http://www.ucl.ac.uk/~ucfagls/ WC1E 6BT. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Another approach is to use the framework provided by package grid. If you want to use R base graphics, you might want to look at package gridBase as well. BTW: There is the book on R Graphics by Paul Murrell ... Best, Uwe Ligges Gavin Simpson wrote:> On Fri, 2006-04-28 at 10:07 +0200, Stefan Semmeling wrote: > >>dear list, >> >>i have a problem using the par function. >> >>in one graphic device i want to have two plots so i tried to use >>par(mfror=c(1,2)). >>of course it worked out, but the height now is twice the length of the width >>for each single plot. >>what i actually wanted is something like par(mfrow=c(2,2)) where only the >>top (or bottom) >>two plots are drawn with entire length proportions of 1 to 2 ( height 1, >>width 2) >>i want to create a pdf figure and can?t figure out how that might work. >>(e.g. the height should be 8 cm, the length 16 cm but each plot should have >>the proportion 1:1(height:width)) >> >>thanks for any help. >> >>stefan > > > Is this what you mean: > > Square plots, 1 row, 2 cols, 8 by 16cm > > cmToInch <- 0.393700787 > pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * > cmToInch, pointsize = 10, onefile = FALSE) > opar <- par(mfrow = c(1,2), pty = "s") > plot(rnorm(100), rnorm(100)) > plot(rnorm(100), rnorm(100)) > par(opar) > dev.off() > > or same aspect ratio: > > pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * > cmToInch, pointsize = 10, onefile = FALSE) > opar <- par(mfrow = c(1,2)) > plot(rnorm(100), rnorm(100), asp = 1) > plot(rnorm(100), rnorm(100), asp = 1) > par(opar) > dev.off() > > or both: > > pdf("test.pdf", paper = "special", height = 8*cmToInch, width = 16 * > cmToInch, pointsize = 10, onefile = FALSE) > opar <- par(mfrow = c(1,2), pty = "s") > plot(rnorm(100), rnorm(100), asp = 1) > plot(rnorm(100), rnorm(100), asp = 1) > par(opar) > dev.off() > > HTH, > > G >
Hi This could be near to what you want. You need to play around with width and height to get the exact result you want.> pdf("test.pdf", width=4, height=8) > par(mfrow=c(2,1)) > plot(1:10,1:10) > plot(10:1,1:10) > dev.off()HTH Petr On 28 Apr 2006 at 10:07, Stefan Semmeling wrote: From: "Stefan Semmeling" <trittihn at web.de> To: <r-help at stat.math.ethz.ch> Date sent: Fri, 28 Apr 2006 10:07:53 +0200 Subject: [R] par(mfror=c(1,2))> dear list, > > i have a problem using the par function. > > in one graphic device i want to have two plots so i tried to use > par(mfror=c(1,2)). > of course it worked out, but the height now is twice the length of the > width for each single plot. what i actually wanted is something like > par(mfrow=c(2,2)) where only the top (or bottom) two plots are drawn > with entire length proportions of 1 to 2 ( height 1, width 2) i want > to create a pdf figure and can?t figure out how that might work. (e.g. > the height should be 8 cm, the length 16 cm but each plot should have > the proportion 1:1(height:width)) > > thanks for any help. > > stefan > > ______________________________________________ > R-help at 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.htmlPetr Pikal petr.pikal at precheza.cz
One simple solution is to use the layout function in place of par. For example:> layout(rbind(c(0,1,1,0),c(0,2,2,0))) > hist(rnorm(100)) > hist(rnorm(10000))Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111 -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Stefan Semmeling Sent: Friday, April 28, 2006 2:08 AM To: r-help at stat.math.ethz.ch Subject: [R] par(mfror=c(1,2)) Sensitivity: Personal dear list, i have a problem using the par function. in one graphic device i want to have two plots so i tried to use par(mfror=c(1,2)). of course it worked out, but the height now is twice the length of the width for each single plot. what i actually wanted is something like par(mfrow=c(2,2)) where only the top (or bottom) two plots are drawn with entire length proportions of 1 to 2 ( height 1, width 2) i want to create a pdf figure and can?t figure out how that might work. (e.g. the height should be 8 cm, the length 16 cm but each plot should have the proportion 1:1(height:width)) thanks for any help. stefan ______________________________________________ R-help at 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