[R] xyplot, panel.abline, from, to

Afshartous, David DAfshartous at med.miami.edu
Tue Jul 28 15:23:58 CEST 2009


All,

I'm trying to truncate some lines that are added to an xyplot via
panel.abline to allow additional space for inserted text.  According to
?panel.abline it seems like "from" and "to" will do the trick but it does
not work for the sample code below.  Any hints much appreciated.

Cheers,
David

x = seq(1,8)
y.1 = .6*x + 3.5 + rnorm(8, 0, .5); y.2 = .4*x + 1 + rnorm(8,0, .5)
data.ex = data.frame( x.var = c(x,x), y.var = c(y.1, y.2), id = c(rep("y1",
8), rep("y2", 8)))

xyplot( y.var ~ x.var, data = data.ex, groups = id, pch = 16, panel =
function(...) {
           panel.abline(a = 2, b = .5, lty = 1,  from = 1, to = 8)
           panel.abline(a = 3.5, b = .6, lty = 3, from = 1, to = 8)
           panel.abline(a = 1, b = .4, lty = 4, from = 1, to = 8)
           panel.xyplot(...)
       }, scales = list(y = list(limits = c(0,10)), x = list(limits =
c(0,12)) ))
       




More information about the R-help mailing list