[R] putting reference lines or grids into the background of a plot

RINNER Heinrich HEINRICH.RINNER at tirol.gv.at
Thu Sep 3 17:24:31 CEST 2009


Dear R-community,

using R.2.9.1, how do you put reference lines or grids into the _background_ of a plot?
For example:

barplot(3:1)
abline(h = seq(0.5, 2.5 ,0.5), col = "red", lty = "dashed")

-> The lines are before the bars (and the line parts going through the bars might be considered as "chart junk", I suppose).

Now, in this toy example I could just do the plot again to get the desired result:

barplot(3:1, add = TRUE)

But is that really in general the "natural" way to do this?
Maybe I am just missing some graphical parameter that I could change (though I was not able to find one)...

Thanks,
Heinrich.




More information about the R-help mailing list