Re: [R] par(mfrow=c(3,4)) problem
> Sarah Goslee > on Wed, 30 May 2018 05:03:56 -0400 writes: > Hi, > You're mixing base plot and ggplot2 grid graphics, which as you've > discovered doesn't work. > Here's av strategy that does: > https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html > This vignette has a good overview, well as info specific to that package. > Sarah A very nice vignette indeed! Didn't know about these. Thank you, Sarah, and thanks to the author, Baptiste Auguie ! Martin > On Wed, May 30, 2018 at 4:43 AM greg holly wrote: >> Hi all; >> >> I need to put 12 different plot2 into the same matrix. So my array for the >> matrix will be par(mfrow=c(3,4)). I am running ggplot2 to produce my 12 >> plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix. >> >> my basic R codes for each plot is >> par(mfrow=c(3,4)) >> library(ggplot2) >> p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight, >> color=Showing_rate)) + >> . >> . >> >> Best regards, >> >> Greg >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > -- > Sarah Goslee > http://www.stringpage.com > http://www.sarahgoslee.com > http://www.functionaldiversity.org > [[alternative HTML version deleted]] > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] par(mfrow=c(3,4)) problem
Hi, You're mixing base plot and ggplot2 grid graphics, which as you've discovered doesn't work. Here's av strategy that does: https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html This vignette has a good overview, well as info specific to that package. Sarah On Wed, May 30, 2018 at 4:43 AM greg holly wrote: > Hi all; > > I need to put 12 different plot2 into the same matrix. So my array for the > matrix will be par(mfrow=c(3,4)). I am running ggplot2 to produce my 12 > plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix. > > my basic R codes for each plot is > par(mfrow=c(3,4)) > library(ggplot2) > p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight, > color=Showing_rate)) + > . > . > > Best regards, > > Greg > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] par(mfrow=c(3,4)) problem
Hi You combine basic graphic (par) and grid graphic (ggplot), which is possible but not strightforward. You could check it e.g. par(mfrow=c(1,2)) plot(1,1) plot(1,2) library(ggplot2) d <- ggplot(diamonds, aes(carat, price)) d + geom_point(alpha = 1/10) d + geom_point(alpha = 1/20) In grid graphic you could use ?facet_grid to get multiple plots on one page. Or you could use Google and find www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/ http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/81-ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/ Cheers Petr Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of greg holly > Sent: Wednesday, May 30, 2018 10:43 AM > To: r-help mailing list > Subject: [R] par(mfrow=c(3,4)) problem > > Hi all; > > I need to put 12 different plot2 into the same matrix. So my array for the > matrix will be par(mfrow=c(3,4)). I am running ggplot2 to produce my 12 > plots. > For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix. > > my basic R codes for each plot is > par(mfrow=c(3,4)) > library(ggplot2) > p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight, > color=Showing_rate)) + > . > . > > Best regards, > > Greg > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person repr
Re: [R] par(mfrow=c(3,4)) problem
You might find the patchwork library helpful (plot_layout function) https://github.com/thomasp85/patchwork I'm not sure if it's on CRAN but you can devtools::github_install it. Cheers, Alex On Wed, May 30, 2018 at 6:42 PM, greg holly wrote: > Hi all; > > I need to put 12 different plot2 into the same matrix. So my array for the > matrix will be par(mfrow=c(3,4)). I am running ggplot2 to produce my 12 > plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix. > > my basic R codes for each plot is > par(mfrow=c(3,4)) > library(ggplot2) > p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight, > color=Showing_rate)) + > . > . > > Best regards, > > Greg > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] par(mfrow=c(3,4)) problem
Hi all; I need to put 12 different plot2 into the same matrix. So my array for the matrix will be par(mfrow=c(3,4)). I am running ggplot2 to produce my 12 plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix. my basic R codes for each plot is par(mfrow=c(3,4)) library(ggplot2) p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight, color=Showing_rate)) + . . Best regards, Greg [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] par(mfrow) for heatmap plots
The answer is "don't do that" because that function abuses par. Use lattice or ggplot2 with grid graphics to plot multiple heatmaps. https://stackoverflow.com/questions/15114347/to-display-two-heatmaps-in-same-pdf-side-by-side-in-r -- Sent from my phone. Please excuse my brevity. On July 23, 2017 5:11:32 AM PDT, Brian Smithwrote: >Hi, > >I was trying to use par(mfrow) to put 4 heatmaps on a single page. >However, >I get one plot per page and not one page with 4 plots. What should I >modify? Test code is given below: > >test = matrix(rnorm(60), 20, 3) > >pdf(file='test.pdf',width=10,height=8) >par(mfrow=c(2,2)) >heatmap(test) >heatmap(test) >heatmap(test) >heatmap(test) >dev.off() > >thanks! > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] par(mfrow) for heatmap plots
Dear Brian If you look at ?heatmap and the second paragraph of the Note you will see that it is behaving according to its documentation. On 23/07/2017 13:11, Brian Smith wrote: Hi, I was trying to use par(mfrow) to put 4 heatmaps on a single page. However, I get one plot per page and not one page with 4 plots. What should I modify? Test code is given below: test = matrix(rnorm(60), 20, 3) pdf(file='test.pdf',width=10,height=8) par(mfrow=c(2,2)) heatmap(test) heatmap(test) heatmap(test) heatmap(test) dev.off() thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. --- This email has been checked for viruses by AVG. http://www.avg.com -- Michael http://www.dewey.myzen.co.uk/home.html __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] par(mfrow) for heatmap plots
Hi, I was trying to use par(mfrow) to put 4 heatmaps on a single page. However, I get one plot per page and not one page with 4 plots. What should I modify? Test code is given below: test = matrix(rnorm(60), 20, 3) pdf(file='test.pdf',width=10,height=8) par(mfrow=c(2,2)) heatmap(test) heatmap(test) heatmap(test) heatmap(test) dev.off() thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] par(mfrow)
Hi, I have some problems using the par function: I want to split the screen into 2 rows and 4 col and I type par(mfrow=c(2, 4)) but when I do that, instead of setting a graphical parameter, it creates a white Quarz. I'm currently using the R base version for Mac Os, 3.0.3 . Could you give me an help? Thank you very much, Emanuele __ R-help@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.
Re: [R] par(mfrow)
Hi, re: I have some problems using the par function: I want to split the screen into 2 rows and 4 col and I type par(mfrow=c(2, 4)) but when I do that, instead of setting a graphical parameter, it creates a white Quarz. I'm currently using the R base version for Mac Os, 3.0.3 . Could you give me an help? Thank you very much, But that's correct, if you don't plot something afterwards. Try plotting 8 x-y graphs, then you'll see that 8 small plot will appear (unless the margins will prove to be too large). Good luck, Franklin Bretschneider Dept of Biology Utrecht University brets...@xs4all.nl __ R-help@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.
[R] par(mfrow=c(1,3)) and postscript(file=)
I am printing three graphs into the same page using par(mfrow=c(1,3)) and the I want to save the file as postscript format using postscript() When input the postscript file into the manuscript the three graphs appear on separate pages. What have I missed and done wrong? Thank you in advance! Cheers, Patrik [[alternative HTML version deleted]] __ R-help@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.
Re: [R] par(mfrow=c(1,3)) and postscript(file=)
Probably you need to put the par() function after the postscript() function - the par changes apply only to the current device, and there's no postscript device until you start it. But since you haven't provided an example, it's impossible to be certain. Sarah On Friday, May 24, 2013, Öhagen Patrik wrote: I am printing three graphs into the same page using par(mfrow=c(1,3)) and the I want to save the file as postscript format using postscript() When input the postscript file into the manuscript the three graphs appear on separate pages. What have I missed and done wrong? Thank you in advance! Cheers, Patrik -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@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.
[R] par(mfrow) or split.screen with climatol roseavent plot?
Hi I trying to add a wind rose as a plot together with other plots. Im unsing the roseavent function from the climatol package. Ive tried par(mfrow=c(2,2)) but when plotting the windrose: rosavent(windfreq_rose,4,3,ang=-3*pi/16,main=Windrose) it skips one position, and when plotting the next one it blanks everything else. Ive also tried split.screen, but the roseavent only blanks everything else as it is plotted. Does anyone have an idea how I can add my windrose without haveing to cut and paste it in gimp afterwards? Kind regards Jan __ R-help@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.
Re: [R] par(mfrow) or split.screen with climatol roseavent plot?
On Jul 31, 2012, at 7:21 AM, Jan Näs wrote: Hi I trying to add a wind rose as a plot together with other plots. Im unsing the roseavent function from the climatol package. Ive tried par(mfrow=c(2,2)) but when plotting the windrose: rosavent(windfreq_rose,4,3,ang=-3*pi/16,main=Windrose) it skips one position, and when plotting the next one it blanks everything else. Many specialized plotting routines will override the par settings. Notice that in the rosavent code you find: par(mar = margen, new = FALSE) You may need to do a bit of code hacking to get your desired 2 x 2 arrangement. Ive also tried split.screen, but the roseavent only blanks everything else as it is plotted. Does anyone have an idea how I can add my windrose without haveing to cut and paste it in gimp afterwards? Kind regards Jan -- David Winsemius, MD Alameda, CA, USA __ R-help@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.
[R] par mfrow in function problem
Hi all, I defined the following # myhist=function(x){ hist(x,xlab=,main=) h=hist(x) xfit=seq(min(x),max(x),length=100) yfit=dnorm(xfit,mean(x),sd=sd(x)) yfit=yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col=blue, lwd=2) } # individually, it worked fine however, if I used par(mfrow=c(2,2)) each time i run myhist it produces TWO plots, one without the 'lines', and one with the 'lines' why is that?? Thanks. casper -- View this message in context: http://r.789695.n4.nabble.com/par-mfrow-in-function-problem-tp3036745p3036745.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] par mfrow in function problem
Dear Casper, This is because you create two histograms, the first with the direct call to hist(), the second at: h = hist(x). That is also why even though you set the xlab and main to be blank in your first one,the histogram with the normal line added actually was titled. Normally, hist() just overwrites the plot in the current device, but since there are 4 slots in the device (par(mfrow = c(2, 2))), you then saw multiple histograms. You can avoid this by setting the plot = FALSE argument in the histogram you do not want plotted. Here is how I would revise it: par(mfrow=c(2,2)) # myhist=function(x){ hist(x,xlab=,main=) h=hist(x, plot = FALSE) xfit=seq(min(x),max(x),length=100) yfit=dnorm(xfit,mean(x),sd=sd(x)) yfit=yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col=blue, lwd=2) } # ## an example myhist(rnorm(400)) HTH, Josh On Wed, Nov 10, 2010 at 11:31 AM, casperyc caspe...@hotmail.co.uk wrote: Hi all, I defined the following # myhist=function(x){ hist(x,xlab=,main=) h=hist(x) xfit=seq(min(x),max(x),length=100) yfit=dnorm(xfit,mean(x),sd=sd(x)) yfit=yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col=blue, lwd=2) } # individually, it worked fine however, if I used par(mfrow=c(2,2)) each time i run myhist it produces TWO plots, one without the 'lines', and one with the 'lines' why is that?? Thanks. casper -- View this message in context: http://r.789695.n4.nabble.com/par-mfrow-in-function-problem-tp3036745p3036745.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
Hi! I think you've got already all useful solutions, but I usually just change mfrow to c(2,2). There is then free space left, but I usually edit my graphs in Illustrator anyway. Ivan Le 9/8/2010 21:01, (Ted Harding) a écrit : Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0- rnorm(50) ; Y0- rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding)ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@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.
[R] 'par mfrow' and not filling horizontally
Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
Look at the squishplot function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Ted Harding Sent: Wednesday, September 08, 2010 1:01 PM To: r-h...@stat.math.ethz.ch Subject: [R] 'par mfrow' and not filling horizontally Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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. __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
Try par(pty=s). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ted.hard...@manchester.ac.uk Sent: Wednesday, September 08, 2010 12:01 PM To: r-h...@stat.math.ethz.ch Subject: [R] 'par mfrow' and not filling horizontally Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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. __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
On Sep 8, 2010, at 2:01 PM, Ted Harding wrote: Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. Ted, Try this: set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) # add pty = s par(mfrow=c(2, 1), mfg = c(1, 1), cex = 0.5, pty = s) plot(X0, Y0, pch = +, col = blue, xlim = c(-3, 3), ylim = c(-3, 3), xlab = X, ylab = Y, main = My Plot, asp = 1) par(mfg = c(2, 1)) plot(X0, Y0, pch = +, col = blue, xlim= c(-3, 3), ylim = c(-3, 3), xlab = X, ylab = Y, main = My Plot, asp = 1) See ?par and 'pty', which defaults to m. HTH, Marc Schwartz __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
Ted: ?layout Is this close to what you want? layout(matrix(1:2, nrow=2),wid=1,heigh=c(1,1), resp= TRUE) set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) On Wed, Sep 8, 2010 at 12:01 PM, Ted Harding ted.hard...@manchester.ac.uk wrote: Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
On 08-Sep-10 19:16:15, Bert Gunter wrote: Ted: ?layout Is this close to what you want? layout(matrix(1:2, nrow=2),wid=1,heigh=c(1,1), resp= TRUE) set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) Thanks Greg, William, Marc Bert for the suggestions. It seems that Bert's suggestion of 'layout' may work best for my real example (the one I posted was a simple one). It is also necessary to add par(pty=s). Greg: I must study squishplot() -- it looks useful. William, Marc: I had tried pty=s in my real example (I inadvertently omitted it from the dummy example I posted), but it still did not work -- see Case B of the real example below. Anyway, here is an instance of the real problem. DISCLAIMER: This is being done as an exploration of concept and does not necessarily represent my true state of mind ... ## Code common to all approaches (Alterbative continuations A and B): library(MASS) M - 10 ; N - 2 ; plur - 's set.seed(54321) mu - (-3)+6*(0:(M-1))/(M-1) mu - rep(mu, N) ## M evenly spaced on (-3,3) Y - matrix(rnorm(M*N,mean=mu),ncol=N) ## N Y's for each mu KDE - kde2d(x=mu, y=Y, h=2.5, n=100, lims=c(-5,5,-5,5,-5.0,5.0)) S.x - KDE$x ; S.y - KDE$y ; S.z - KDE$z ## For each value of Y in the KDE grid, find the mu with max KDE: Mxs - numeric(100) for(j in (1:100)){ Mxs[j] - S.x[which(S.z[,j]==max(S.z[,j]))] } ## A: Using Bert's 'layout' approach with pty=s as well: layout(matrix(1:2, nrow=2),wid=1,height=c(1,1), resp=TRUE) par(cex=0.5,pty=s) plot(mu,Y,pch=+,col=blue,asp=1,xlim=c(-5,5),ylim=c(-5,5), xlab=True mu, ylab=Sampled Y's, main=paste(KDE for (mu,Y), M, mu's, ,N, Y,plur, per mu,sep=)) contour(S.x, S.y, S.z, nlevels=7, drawlabels=FALSE, add=TRUE) lines(S.x,S.y,col=green) for(j in (1:100)){ Mxs[j] - S.x[which(S.z[,j]==max(S.z[,j]))] } lines(Mxs,S.x,col=red) plot(S.x[1:100],Mxs[1:100],asp=1,pch=+,col=red, xlim=c(-5,5),ylim=c(-5,5), xlab=Future Observed Y,ylab=MLE of mu by KDE, main=MLE of mu by KDE for this Sim vs Future Y) lines(c(-3,3),c(-3,3),col=green) lines(c(-3,-3),c(-3,3)) ; lines(c( 3, 3),c(-3,3)) text(0,3.5,-- Range of True mu used --) ##C: Using par(pty=s) with par(mfrow) leaving out 'layout': plot.new() par(mfrow=c(2,1),mfg=c(1,1),cex=0.5,pty=s) plot(mu,Y,pch=+,col=blue,asp=1,xlim=c(-5,5),ylim=c(-5,5), xlab=True mu, ylab=Sampled Y's,pty=s, main=paste(KDE for (mu,Y), M, mu's, ,N, Y,plur, per mu,sep=)) contour(S.x, S.y, S.z, nlevels=7, drawlabels=FALSE, add=TRUE) lines(S.x,S.y,col=green) for(j in (1:100)){ Mxs[j] - S.x[which(S.z[,j]==max(S.z[,j]))] } lines(Mxs,S.x,col=red) par(mfg=c(2,1)) plot(S.x[1:100],Mxs[1:100],asp=1,pch=+,col=red, xlim=c(-5,5),ylim=c(-5,5), xlab=Future Observed Y,ylab=MLE of mu by KDE, main=MLE of mu by KDE for this Sim vs Future Y) lines(c(-3,3),c(-3,3),col=green) lines(c(-3,-3),c(-3,3)) ; lines(c( 3, 3),c(-3,3)) text(0,3.5,-- Range of True mu used --) # Anyway, thanks! It has helped. Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 21:39:53 -- XFMail -- __ R-help@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.
Re: [R] 'par mfrow' and not filling horizontally
remove your asp=1 and try again to see if that is what you want. On Wed, Sep 8, 2010 at 3:01 PM, Ted Harding ted.hard...@manchester.ac.uk wrote: Greetings, Folks. I'd appreciate being shown the way out of this one! I've been round the documentation in ever-drecreasing circles, and along other paths, without stumbling on the answer. The background to the question can be exemplified by the example (no graphics window open to start with): set.seed(54321) X0 - rnorm(50) ; Y0 - rnorm(50) par(mfrow=c(2,1),mfg=c(1,1),cex=0.5) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) par(mfg=c(2,1)) plot(X0,Y0,pch=+,col=blue,xlim=c(-3,3),ylim=c(-3,3), xlab=X,ylab=Y,main=My Plot,asp=1) As you will see, both plots have been extended laterally to fill the plotting area horizontally, hence extend from approx X = -8 to approx X = +8 (on my X11 display), despite the xlim=c(-3,3); however, the ylim=c(-3,3) has been respected, as has asp=1. What I would like to see, independently of the shape of the graphics window, is a pair of square plots, each with X and Y ranging from -3 to 3, even if this leaves empty space in the graphics window on either side. Hints? With thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Sep-10 Time: 20:01:19 -- XFMail -- __ R-help@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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@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.
[R] par(mfrow = ) resets par('cex'), not reduces it
Hello group! I use R 2.8.0 . I've just found out that par(mfrow =) *resets* par ('cex'), not reduces it as documented. To reproduce: par(cex = 0.5) par(mfrow = c(2, 2)) print(par('cex')) It outputs 0.83, not 0.415 as expected. Particularly such a behavior makes plot.acf effectively ignore par ('cex') value for multivariate case. I guess there are more situations where the documented behavior would be more appropriate. I think it is bug in par implementation not in documentation. Could anyone comment on this? Andrey __ R-help@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.
Re: [R] par(mfrow=c(2,4))
reproducible code please. On Mon, Oct 20, 2008 at 3:22 PM, phoebe kong [EMAIL PROTECTED] wrote: Hi All, I'm going to draw 8 plots in one page. I want the plots to be arranged in two rows, each row has 4 plots. So, I set the it par(mfrow=c(2,4)). However, there might be too many plots in a page, all the 8 plots were drawn in triangular shape, which makes the x-y coordinate scale not in same length, the x-axis length is much shorter than the y-axis length. Could anybody let me know how to make the x-y coordinate length be the same, like the square box? Thanks in advance. Sityee __ R-help@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. -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
[R] par(mfrow=c(4,2)) vs. lattice
I have had good sucess with the par(mfrow=c(#,#)) for formating graphs and they look good to me. I have seen a lot of use of the lattice package and thought I would go fishing on the list for y'all's comments. Is there a time when lattice would be easier more appropriate for certain graphics over par(mfrow(#,#)). Just wondering Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@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.
Re: [R] par(mfrow=c(4,2)) vs. lattice
FWIW: I use lattice exclusively. One difference from the mfrow approach is that lattice automatically provides (if desired) the same scaling on all plots, necessary to make visual comparisons. It also provides an easy way to appropriately label and and arrange the plots, as well as to provide standard enhancements (e.g. a benchmark curve or line on all graphs) on all. Again, this makes visual comparison among the plots possible, which is what I mostly have to do. Customizable panel functions give me all the flexibility and control I need. Generally, it's not hard to write your own, using the extensive building blocks Deepayan has provided. All of this is possible through mfrow of course --- you just have to do it manually. Lattice makes it easy (for me!). Note: there **is** a considerable learning curve, but Deepayan has done an exemplary job of documenting lattice, and his new book is a well-written and extensive resource for self-learning (all IMHO, of course). Just my $.02. Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of stephen sefick Sent: Tuesday, June 10, 2008 10:10 AM To: r-help@r-project.org Subject: [R] par(mfrow=c(4,2)) vs. lattice I have had good sucess with the par(mfrow=c(#,#)) for formating graphs and they look good to me. I have seen a lot of use of the lattice package and thought I would go fishing on the list for y'all's comments. Is there a time when lattice would be easier more appropriate for certain graphics over par(mfrow(#,#)). Just wondering Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] par(mfrow=c(4,2)) vs. lattice
mfrow is for classic graphics and when the graphs are unrelated. lattice is for grid graphics and typically when the panels are related such as being the same plot but conditioned on different factor levels. These are typical uses only as one can write arbitary panels with lattice and produce related graphs using mfrow with some extra work. On Tue, Jun 10, 2008 at 1:09 PM, stephen sefick [EMAIL PROTECTED] wrote: I have had good sucess with the par(mfrow=c(#,#)) for formating graphs and they look good to me. I have seen a lot of use of the lattice package and thought I would go fishing on the list for y'all's comments. Is there a time when lattice would be easier more appropriate for certain graphics over par(mfrow(#,#)). Just wondering Stephen -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.