Skip to content

panel.first problem when plotting with formula

6 messages · Peter Ehlers, Gene Leynes, David Winsemius

#
On 2011-05-23 16:54, Gene Leynes wrote:
No silver bullet, but this seems to work:

   plot(y ~ x, data=dat, type="n")
   points(y ~ x, data=dat, panel.first=bgfun())

(I think that plot.formula may need a fix but
offhand I can't see whether that's easy or hard.)

Peter Ehlers
#
On May 24, 2011, at 11:42 PM, Gene Leynes wrote:

            
plot(dat, panel.first=bgfun() ) # succeeds

So the problem is not with plot.data.frame.

So someplace in the processing of dots and the handoff to

do.call(funname, c(list(mf[[i]], y, ylab = yl,  xlab = xl), dots))

... where funname = "plot", the dot identities do not get honored. The  
'plot" function is where it all started, but the first argument is now  
mf[[i]], and is that is now a numeric vector. So I think it gets  
handed off to plot.default,  which sets panel.first to NULL.
#
On May 25, 2011, at 5:56 PM, Gene Leynes wrote:

            
Apparently not the first time he has been called upon to do so. Here  
is a similar question, albeit with no answer (at least in Baron's  
archive) at that time.

http://finzi.psych.upenn.edu/Rhelp10/2009-September/210328.html

(... the link to the ancient bug is broken.)

But plot.formula promises to pass "..."  arguments to later "hand  
offs" and apparently it munges up the 'dots' in a manner that  
plot.data.frame does not. In fact, plot.formula gets handed back to  
generic `plot`. Prof Ripley obviously has an understanding of the term  
`expression` that surpasses mine. Does your understaning of his reply  
extend to explaining why plot.data.frame works with our naive  
invocation of panel.first while his suggested syntax does not:

plot(dat, panel.first=quote( bgfun() ) ) # Fails.
plot(dat, panel.first= bgfun()  )   # Succeeds.

So I it still appears there is a demonstrable degree of inconsistency,  
even if there is no "bug".
Yes, I did read the help page. I also looked at the code (of  
plot.formula, plot.data.frame, and plot.default)  and made a good  
faith effort at following the flow of data through that code by  
inserting print and str statements at what appeared to be critical  
points so I could see where plot.formula was "going" and what it was  
being given to work with.
I also tried using just panel.first=bgfun as I would have with lattice  
calls, and it did not succeed in any application.