Most clever! I'd completely forgotten about panel.segments. Paul Murrell wrote:
>Here's one way to vectorize the lines ... > >my.panel2 <- function(x, y, cex=1, ...){ > panel.xyplot(x, y, cex = cex, ...) > a <- 0.5 * cex * > convertWidth(unit(1, "char"), "native", valueOnly=TRUE) > b <- 0.5 * cex * > convertHeight(unit(1, "char"), "native",valueOnly=TRUE) > dx <- diff(x) > dy <- diff(y) > f <- 1 / sqrt((dx/a)^2 + (dy/b)^2) > n <- length(x) > x1 <- x[1:(n-1)] + f*dx > x2 <- x[2:n] - f*dx > y1 <- y[1:(n-1)] + f*dy > y2 <- y[2:n] - f*dy > i <- f < 0.5 > panel.segments(x1[i], y1[i], x2[i], y2[i]) >} > >Paul >
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html