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 Jim Lemon
> Sent: Saturday, January 24, 2009 2:51 AM
> To: r-help at r-project.org
> Subject: [R] Is abline misbehaving?
>
> Hi experts,
> I was graciously offered a function to enhance abline by restricting
> the
> extent of the line to less than the plotting region. This seems a
> useful
> idea, and it looked like the easiest way to program it was to set up a
> clipping region with "clip", draw the abline and then restore the
> previous clipping region. Let us call this function ablineclip. After
> quite a bit of testing, I have found that the first call to ablineclip
> ignores the clipping region. It's not that simple. Successive calls to
> ablineclip respect the clipping region, even if it changes. I can
> reproduce the behavior like this:
>
> plot(-3:3,-3:3)
> clip(-2,2,-2,2)
> abline(v=0)
> clip(-2,2,-2,2)
> abline(h=0)
>
>
> The first abline ignores the clip, the second respects it. I have
> programmed around this, with the pathetic kludge of calling "abline"
> with a line outside the plotting area, calling "clip" a second time,
> and
> then calling "abline" with the line that was requested. While this
> works, my place in programming history will be ineradicably compromised
> if the Programmers' Hall of Fame ever finds out. Any suggestions?
>
> R-2.7.2
> FC9 Linux
>
> Jim
>
> ______________________________________________
> 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.