> -----Original Message----- > From: [EMAIL PROTECTED] on behalf of Maura E Monville > Sent: Fri 12/28/2007 2:18 PM > To: [EMAIL PROTECTED] > Subject: [R] two plots on the same page > > I'd like to know why I cannot get a plot and the QQnorm in the same sheet. > The commands are simple but: > > library(nlme) > glmod1 <- gls(upfmla,correlation=corAR1(),method="ML") > summary(glmod1) > par(mfrow = c(2,1)) > plot(glmod1, main="GLS Residuals vs. GLS Fitted") > qqnorm(glmod1) > > No matter what (I tried different permutations of the plotting commands) the > second drawing is overlapped to the first one instead of being placed > underneath it on the same page. > How come? >
Because glmod1 is of class "gls" > class(glmod1) [1] "gls" so when you plot it you are invoking plot.gls() See the help for function plot.gls() in the nlme library. > ?plot.gls reports that the value of a call is Value a diagnostic Trellis plot. so you are dealing with Trellis plots handled by the lattice package. Trellis plots do not use the par() settings used by regular plots. Here's one way to do it. (I substituted an example from nlme since I don't have your data and "upfmla" object. library(nlme) glmod1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary, correlation = corAR1(form = ~ 1 | Mare)) summary(glmod1) plot1 <- plot(glmod1, main="GLS Residuals vs. GLS Fitted") plot2 <- qqnorm(glmod1) print(plot1, split = c(1, 1, 1, 2), more = TRUE) print(plot2, split = c(1, 2, 1, 2)) Try something like this. The 'split' mechanism works for me and I get both plots on one page. Remember also that you can save the output of trellis plot commands and print them later. Trellis plots do not always print right away - in many situations you must explicitly wrap your trellis plot command with print() before it will render on a graphics device. You can read more about putting multiple trellis plots on a page in the help page for print.trellis in the lattice package. Hope this helps. After you master the lattice package you can go to that New Years party and celebrate! Steven McKinney Statistician Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre email: smckinney +at+ bccrc +dot+ ca tel: 604-675-8000 x7561 BCCRC Molecular Oncology 675 West 10th Ave, Floor 4 Vancouver B.C. V5Z 1L3 Canada > Thank you very much. > Happy New Year, > Maura > > > > > > -- > Maura E.M > > [[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.