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@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.

Reply via email to