Skip to content
Prev 167773 / 398502 Next

plot: abline() - define line length

I use this function (a lot):

ablinepiece <- function(a=NULL,b=NULL,reg=NULL,from,to,...){

    # Borrowed from abline
    if (!is.null(reg)) a <- reg

    if (!is.null(a) && is.list(a)) {
            temp <- as.vector(coefficients(a))

        if (length(temp) == 1) {
            a <- 0
            b <- temp
        }
        else {
            a <- temp[1]
            b <- temp[2]
        }
    }

    segments(x0=from,x1=to,
             y0=a+from*b,y1=a+to*b,...)

}



-------------------------------------------------
Remko Duursma
Post-Doctoral Fellow

Centre for Plant and Food Science
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
On Thu, Jan 22, 2009 at 11:01 AM, J?rg Gro? <joerg at licht-malerei.de> wrote: