Hi, is there a way to define, that a line drawn via abline() should only go from for example -2 to 1 on the x-axis (with something working similiar to xlim()) ? thanks for any help!
plot: abline() - define line length
4 messages · Remko Duursma, Jörg Groß, Greg Snow
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:
Hi, is there a way to define, that a line drawn via abline() should only go from for example -2 to 1 on the x-axis (with something working similiar to xlim()) ? thanks for any help!
______________________________________________ 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.
Thanks, that's great! Am 22.01.2009 um 01:18 schrieb Remko Duursma:
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:
Hi, is there a way to define, that a line drawn via abline() should only go from for example -2 to 1 on the x-axis (with something working similiar to xlim()) ? thanks for any help!
______________________________________________ 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.
Use either the 'clip' function from the graphics package, or the 'clipplot' function from the TeachingDemos package. Hope this helps,
Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111 > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of J?rg Gro? > Sent: Wednesday, January 21, 2009 5:02 PM > To: r-help at r-project.org > Subject: [R] plot: abline() - define line length > > Hi, > > is there a way to define, that a line drawn via abline() should only > go from for example -2 to 1 on the x-axis (with something working > similiar to xlim()) ? > > thanks for any help! > > ______________________________________________ > 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.