[R] Arrow heads at the end of axes
Marc Schwartz
MSchwartz at MedAnalytics.com
Thu Oct 21 16:27:40 CEST 2004
On Thu, 2004-10-21 at 09:04, Henrik Andersson wrote:
> Marc Schwartz wrote:
>
> > On Thu, 2004-10-21 at 07:12, Henrik Andersson wrote:
> >
> >>I would like to have arrow heads at the end of my axes, since I am
> >>plotting variable where the absolute amount is irrelevant, there is not
> >>supposed to be numbers on the axes.
> >>
> ...
> >
> >
> > You can do something like this:
> >
> > plot(rnorm(10), axes = FALSE)
> >
> > # Get the axis ranges
> > u <- par("usr")
> >
> > # Use arrows() to draw the axis lines, adding the arrowheads
> > # Use the par("usr") values to specify the end points of the lines
> > # Setting 'xpd = TRUE' allows for the arrowhead to be drawn outside
> > # the plot region as required here
> > arrows(u[1], u[3], u[2], u[3], code = 2, xpd = TRUE)
> > arrows(u[1], u[3], u[1], u[4], code = 2, xpd = TRUE)
> >
> > See ?arrows for additional options to define the arrows.
> >
> > HTH,
> >
> > Marc Schwartz
>
> Thanks for pointing the direction (seriously), the looks of the
> arrowheads could still use some improvements, so I used a polygon to
> draw an arrowhead which thanks to your suggestion was possible outside
> the plot region.
>
> Is it my Internet English or normal English that is bad, but was is the
> expansion of 'HTH' ?
>
> Cheers, Henrik
Hope That Helps
A common internet acronym that I suppose we take for granted sometimes.
I had also looked at the possible plot symbols as an alternative. You
could use 'pch = 2' (or 17 or 24) for the y axis (an upward pointing
triangle). However, there is really not an equivalent "side pointing"
triangle for the x axis.
polygon() is certainly an alternative.
Best regards,
Marc
More information about the R-help
mailing list