[R] abline outside of plot region

Rolf Turner rolf.turner at xtra.co.nz
Sat Apr 30 06:51:20 CEST 2011


On 30/04/11 01:14, Nick Sabbe wrote:
> Hi R people.
>
>
>
> I ran into this problem: I created a plot with errbars, like this:
>
>> errbar(x=c(1,2,3,4), y=c(2,1,3,3), yminus=c(1.5,0.5,2.5,2.5),
> yplus=c(2.5,1.5,3.5,3.5))
>
> Next, I wanted to accentuate some x value with an abline, like this:
>
>> abline(v=2)
>
>
> In one of my R sessions (which admittedly I have had open for quite a while
> now), the abline draws outside of the plotting region of errbars (till the
> edge of my plotting window at least).
>
> I tested for the cause by opening another session (clean) of the same
> version of R (2.13), and running the same set of commands. In this session,
> I do not have this behavior. Conclusion: I must have changed some graphical
> parameter in my original session, but I don't know which one. Do you?
<SNIP>

I think what has happened is not that *you* changed some graphical 
parameter,
but rather that the package Hmisc did.  In a rather strange way.  (I 
*presume*
that you are using the errbar() function out of Hmisc rather than out of the
sfsmisc package --- you didn't say).

For a while I thought that the problem was associated with the 
*installation*
of Hmisc, becomes it seemed to happen only on the first occasion after I
did the install, and on later occasions (quit from R, restart, load Hmisc,
try errbar and abline) the problem did not occur.

But then, about the third time I tried the re-install, the problem never 
happened
at all.  But it ***did*** happen, a couple of times.  So you're not 
imagining it,
you'll be pleased to know.

I think that if it *does* happen to you again, you can fix it by setting

     par(xpd=FALSE)

I checked on par()$xpd a couple of times when the problem occurred,
and got NA, which is consistent with the observed problem.

The whole thing is weird, but.  Gremlins?

     cheers,

         Rolf Turner



More information about the R-help mailing list