There is a "panel.first" argument that can be used with many different types of plots.
plot(x, panel.first=abline(h=-3:3, lty="dotted", col="gray"), pch=16, col="red", cex=3) # red big plotting characters: to show that ablines are drawn before plotting # the result is different from doing the plot first and abline's after that. But this doesn't work with boxplot: ablines are drawn (so panel.first does something) but then overplotted. boxplot(x, panel.first=abline(h=-3:3, lwd=100, col="red")) # lwd=100: this would be absurd if it worked but now I can see only something red flashing # on the screen before the boxplot is drawn Maybe there are some extra parameters to boxplot or bxp (which does the drawing) that could be used (from what I see on the screen I can imagine that the ablines are first drawn but deleted by the white background of boxplot; so it might help to make this background transparent instead of white; but I haven't examined the code so can't be sure this is what bxp does). Or it might be easier to do it with ggplot. Regards, Kenn Konstabel On 9/18/12, John Kane <jrkrid...@inbox.com> wrote: > Not sure if it is quite the same but ggplot2 does this as its default > formatting. > > library(ggplot2) > x<-rnorm(100) > qplot(factor(0),x, geom="boxplot") > > John Kane > Kingston ON Canada > > >> -----Original Message----- >> From: marongiu.lu...@gmail.com >> Sent: Tue, 18 Sep 2012 09:35:47 +0100 >> To: r-help@r-project.org >> Subject: [R] add reference lines (or grid) in background >> >> Dear all, >> >> Is there a simple way to add reference lines in background? I am trying >> with >> abline() or grid() but the lines, since they are executed after the plot >> function, are draw on top. How can I draw such lines beneath the main >> plot? >> Here is an example: >> >> >> >> x<-rnorm(100) >> >> boxplot(x) >> >> abline(h=c(-1,0,1)) >> >> grid(NA, 4, lwd = 2) >> >> >> >> regards, >> >> >> >> Luigi Marongiu, MSc >> >> >> >> >> [[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. > > ____________________________________________________________ > GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at > http://www.inbox.com/smileys > Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and > most webmails > > ______________________________________________ > 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.