[R] panel.first problem when plotting with formula

From: Gene Leynes <gleynes_at_gmail.com>
Date: Mon, 23 May 2011 18:54:52 -0500

I wrote a little function called bgfun that adds gridlines and a background, but it's not working with I plot using the formula.

I have some theories on what's happening, but even if my theory is right, I don't know how to fix it.

Someone have a straightforward silver bullet?

Thank you,


bgfun = function(color='honeydew2',linecolor='grey45', addgridlines=TRUE){

    rect(tmp[1], tmp[3], tmp[2], tmp[4], col=color)     if(addgridlines){

        abline(h=pretty(ylimits,10), lty=2, col=linecolor)
dat = data.frame(x=1:10,y=1:10)

## Works

plot(dat$x, dat$y, panel.first=bgfun())

## Why doesn't this work?

plot(y ~ x, data=dat, panel.first=bgfun())

        [[alternative HTML version deleted]]

R-help_at_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. Received on Tue 24 May 2011 - 04:17:24 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 25 May 2011 - 23:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive