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)) ))
On Tue, Jul 28, 2009 at 09:23:58AM -0400, 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.As far as I understand, 'from' and 'to' are not parameters of panel.abline. Have a look at panel.segements for arbitrary lines (altough you will not be able to use intercept and slope in that case). cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/
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. > >