This is related to an almost 20-year-old observation of Martin Maechler at https://stat.ethz.ch/pipermail/r-devel/1999-September/019601.html.
In matplot(), passing the panel.first argument to plot.default(), e.g.,
matplot((-4:5)^2, panel.first = grid())
does not have the desired effect. This is because matplot evaluates list(...) before the final plot(...) call to retrieve a potential "log" argument (as implemented in r2710), which causes an early evaluation of panel.first. The help page on plot.default accordingly states for panel.first:
Note that this works by lazy evaluation: passing this
argument from other ‘plot’ methods may well not work since it
may be evaluated too early.
I think it would be nice if matplot did support the panel.first argument of plot.default. So to follow up on the discussion referenced above, my real question is:
3) Why not make the "log" argument explicit in matplot() such that the current list(...) evaluation becomes unnecessary?
This seems a good idea to me.
Can you provide a patch to the sources, involving both the
R/*.R and man/*.Rd file?
(In reply to Martin Maechler from comment #1)
> This seems a good idea to me.
> Can you provide a patch to the sources, involving both the
> R/*.R and man/*.Rd file?
No need. I'm doing this myself now. It really is a very good suggestion.
Committed to R-devel in svn rev 74526