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

Peter Ehlers ehlers at ucalgary.ca
Tue Jul 28 15:58:40 CEST 2009


David,
?panel.abline does not indicate that 'from/to' are arguments to
that function. If you read the help page carefully, you'll see
that 'from/to' apply to panel.curve(). Perhaps you thought that
the '...' argument can take 'from/to'; again the help page makes
it clear that those are to be *graphical* parameters.

One quick fix would be to use panel.curve with, e.g. expr set to
a + b*x:
panel.curve(2 + .5*x, ...)

Peter Ehlers

Afshartous, David wrote:
> 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)) ))
>        
> 
> ______________________________________________
> 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.
> 
>




More information about the R-help mailing list