On Fri, 2004-10-01 at 09:31, [EMAIL PROTECTED] wrote:
> I usually use something like
> 
> abline(h=seq(...),col="green")
> abline(v=seq(...),col="green")
> 
> This allows you to have irregularly spaced grid lines if you want. (Say
> for futures expiration dates in my case.)
> 
> Also, as Marc pointed out, you may want to draw the lines or points
> after the grid lines.

<snip>

Also, again with the aid of further caffeine, as noted in the help for
grid(), one can use the 'panel.first' argument in plot() to enable the
creation of the grid prior to the plotting of the data. 

For example:

plot(rnorm(10), panel.first = grid(), pch = 19)

yields the same results and plotting sequence as:

x <- rnorm(10)
plot(x, type = "n")
grid()
points(x, pch = 19)

As an example of using this approach with irregularly space grid lines
and axis tick marks, as per David's point:

plot(rnorm(10), panel.first = abline(v = c(1, 2, 3, 7), col = "grey", 
     lty = "dotted"), 
     pch = 19, xaxt = "n")

axis(1, at = c(1, 2, 3, 7))


There is also a 'panel.last' argument available which, of course, is
executed after all other plotting is done. More information is available
from ?plot.default.

I have not done an exhaustive review of all plotting functions/methods,
but I suspect not all of them support the panel.first and panel.last
arguments.

HTH,

Marc

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to