Simply add the same boxplot over your first graph using par(new=TRUE) x <-1:10 y <-1:5 boxplot(x, y,col="blue") grid(nx=NA, ny=NULL) #grid over boxplot par(new=TRUE) boxplot(x, y,col="blue")#grid behind boxplot
Neuro >From: "Toby Popenfoose" <[EMAIL PROTECTED]> >Reply-To: Toby Popenfoose <[EMAIL PROTECTED]> >To: <[email protected]> >Subject: [R] How to get a grid behind a boxplot >Date: Fri, 28 Apr 2006 19:46:52 -0400 > >I am using R 2.2.1 on a Windows 2000 PC. >When I do a grid() after the boxplot >it overprints the boxplot: > > > boxplot(count ~ spray, data = InsectSprays, col = "lightgray") > > grid(nx=NA, ny=NULL) > > > >if I try the panel.first > > > boxplot(count ~ spray, data = InsectSprays, col = "lightgray", >+ panel.first=grid(nx=NA, ny=NULL)) > > > >I can see the grid flash and go away. > >If I close the device and then try the panel.first, >I do not get a boxplot and the following error message: > > > boxplot(count ~ spray, data = InsectSprays, col = "lightgray", >+ panel.first=grid(nx=NA, ny=NULL)) >Error in abline(h = at, col = col, lty = lty, lwd = lwd) : > plot.new has not been called yet > > > >Same thing when I try pdf device: > > > pdf("test.pdf") > > boxplot(count ~ spray, data = InsectSprays, col = "lightgray", >+ panel.first=grid(nx=NA, ny=NULL)) >Error in abline(h = at, col = col, lty = lty, lwd = lwd) : > plot.new has not been called yet > > dev.off() >null device > 1 > >How can I get the grid behind the boxplot? > >Thank you, >Toby Popenfoose >Donnelley Manufacturing Supervisor >[EMAIL PROTECTED] > >______________________________________________ >[email protected] mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! >http://www.R-project.org/posting-guide.html ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
