[R] Alignment of axes intersection

Greg Snow Greg.Snow at imail.org
Tue May 20 21:37:47 CEST 2008


If the issue is with abline going all the way to the axis rather than stopping at 0 (or other value), then you may want to look at the clip function (allow the default axes, but clip abline to a smaller region), for example:

> plot(0:10,0:10)
> points(0:10,0:10)
> clip(2,8,0,10)
> points(0:10,0:10)
> abline(h=5)

The clipping region is a little tricky (that's the reson for the 2 calls to points after the plot), but it can limit the region of plotting.  Another approach is:

> library(TeachingDemos) # assuming this is installed
> plot(0:10,0:10)
> clipplot( abline(h=5), xlim=c(2,8) )

See the help on clip and/or clipplot for more examples.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111



> -----Original Message-----
> From: David Afshartous [mailto:dafshartous at med.miami.edu]
> Sent: Tuesday, May 20, 2008 10:37 AM
> To: Greg Snow; r-help at r-project.org
> Subject: Re: Alignment of axes intersection
>
>
> Agreed.  The main reason I wanted the change in alignment was
> that I had three curves that were converging to a asymptote,
> and when I drew the horizontal asymptote via abline(), it
> distorted the picture somewhat since the line from abline()
> goes all the way to the y-axis.
>
>
>
>
> On 5/20/08 12:21 PM, "Greg Snow" <Greg.Snow at imail.org> wrote:
>
> > Mathematicians like to have axes cross at 0, the general rule for
> > statistics is to have the axes positioned so that they help you
> > understand the data, but don't interfere with the actual points (or
> > force too much whitespace by being put to far away from the
> data), so the default positioning follows that idea.
> > If you really want the axes to cross at 0 you can do:
> >
> >> plot(0:10, 0:10, axes=FALSE)
> >> axis(1, pos=0)
> >> axis(2, pos=0)
> >
> >
> >
> > --
> > 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 David Afshartous
> >> Sent: Tuesday, May 20, 2008 9:50 AM
> >> To: r-help at r-project.org
> >> Subject: [R] Alignment of axes intersection
> >>
> >>
> >> All,
> >>
> >> Very basic question I can't seem to find the answer to:
> >>
> >> plot(0:10, 0:10)
> >>
> >> The axes intersection is not aligned at (0,0) in the lower left.
> >> How does one force this?
> >>
> >> I searched for graphical parameters under par(graphics) but can't
> >> seem to find it.
> >>
> >> Thanks!
> >> David
> >>
> >> ______________________________________________
> >> 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.
> >>
> >
>
>



More information about the R-help mailing list