Gábor Pozsgai
2009-Aug-30 16:25 UTC
[R] abline does not show on plot if slope differs from 0
Hi, Does anybody have a hint why this does not work? plot(c(1991,2000), c(-1,10))abline(a=6, b=-1, col="dark grey", lty="dashed") It does not generate an error message, but the line does not turn up. If b=0 it works fine. If I change the axes of the plot to plot(c(1,10), c(-1,10)) it does work fine as well. Thanks, Gabor -- Pozsgai G?bor www.coleoptera.hu www.photogabor.com
Gabor Grothendieck
2009-Aug-30 16:34 UTC
[R] abline does not show on plot if slope differs from 0
The intercept, a, is the value when x = 0. Thus if you want y = 6 when x = 1991 then the line is y = 6 - (x-1991) = 1997 - x so a = 1997: abline(a=1997, b=-1, col="dark grey", lty="dashed") On Sun, Aug 30, 2009 at 12:25 PM, G?bor Pozsgai<pozsgaig at gmail.com> wrote:> Hi, > > Does anybody have a hint why this does not work? > > plot(c(1991,2000), c(-1,10))abline(a=6, b=-1, col="dark grey", lty="dashed") > > It does not generate an error message, but the line does not turn up. > > If b=0 it works fine. If I change the axes of the plot to > plot(c(1,10), c(-1,10)) it does work fine as well. > > Thanks, > Gabor > > -- > Pozsgai G?bor > www.coleoptera.hu > www.photogabor.com > > ______________________________________________ > 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. >
jim holtman
2009-Aug-30 16:35 UTC
[R] abline does not show on plot if slope differs from 0
Very simple, look at the x-axis you are plotting with. If you want the line, then use: abline(a=1996, b=-1, col="dark grey", lty="dashed") On Sun, Aug 30, 2009 at 12:25 PM, G?bor Pozsgai<pozsgaig at gmail.com> wrote:> Hi, > > Does anybody have a hint why this does not work? > > plot(c(1991,2000), c(-1,10))abline(a=6, b=-1, col="dark grey", lty="dashed") > > It does not generate an error message, but the line does not turn up. > > If b=0 it works fine. If I change the axes of the plot to > plot(c(1,10), c(-1,10)) it does work fine as well. > > Thanks, > Gabor > > -- > Pozsgai G?bor > www.coleoptera.hu > www.photogabor.com > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?