[R] Arrow heads at the end of axes

Martin Maechler maechler at stat.math.ethz.ch
Thu Oct 21 16:49:19 CEST 2004


>>>>> "Henrik" == Henrik Andersson <h.andersson at nioo.knaw.nl>
>>>>>     on Thu, 21 Oct 2004 16:04:09 +0200 writes:

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

    Henrik> Thanks for pointing the direction (seriously), the
    Henrik> looks of the arrowheads could still use some
    Henrik> improvements, so I used a polygon to draw an
    Henrik> arrowhead which thanks to your suggestion was
    Henrik> possible outside the plot region.

If you are not pleased with the standard arrows(),
I also would like you to note the  p.arrows() function
in CRAN package 'sfsmisc' written by Andreas Ruckstuhl 10 years
ago.  It draws "nicer" (and slower) arrows and allows some
customization of that  [and I see that its help page could use
some retouching..].

    Henrik> Is it my Internet English or normal English that is
    Henrik> bad, but was is the expansion of 'HTH' ?

you can google for "HTH acronym" ... I get it as 1st match already

"Hope that helps" (or "this"),
Martin




More information about the R-help mailing list