Hi,

likely it's not the most elegant way, but it's straight-forward and the
first which popped in my mind:

a <- rnorm(100)
# either
boxplot(a, col="white", border="white")
my.grid <- seq(-4, 4, 0.5)
abline(h=my.grid, col="grey", lty=2)
boxplot(a, col="red", add = TRUE)
# or
boxplot(a, col="white", border="white")
grid(ny=5)
boxplot(a, col="red", add = TRUE)


Ciao,
Carlo Giovanni Camarda


===========================================
Camarda Carlo Giovanni
PhD-Student
Max Planck Institute for Demographic Research
Konrad-Zuse-Strasse 1
18057 Rostock, Germany
Tel:  +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
[EMAIL PROTECTED]
===========================================


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]


+++++
This mail has been sent through the MPI for Demographic Rese...{{dropped}}

______________________________________________
[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

Reply via email to