Skip to content

arrow egdes and lty

4 messages · Matthias Gondan, (Ted Harding), Tóth Dénes +1 more

#
Dear R developers,

I want to draw an arrow in a figure with lty=2. The
lty argument also affects the edge of the arrow, which is 
unfortunate. Feature or bug?

Is there some way to draw an arrow with intact edge, still
with lty=2?

Example code:

plot(1:10)
arrows(4, 5, 6, 7, lty=2)

Best wishes,

Matthias
--
#
On 14-Nov-11 09:57:52, Matthias Gondan wrote:
According to ?arrows, it would seem that there is no
provision to draw the arrow shaft and the arrow head
using different line types with a single call to arrows().

To the extent that this represents the absence of a desirable
feature (since you desire it), I would designate it as a bug.

It can be done with two calls to arrows(), as follows:

  plot(1:10)
  arrows(4, 5, 6, 7, lty=2, length=0)
  arrows(5.99, 6.99, 6, 7, lty=1)

Of course, the first could also be done using lines().

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 14-Nov-11                                       Time: 10:39:32
------------------------------ XFMail ------------------------------
#
Hi,
AFAIK there is no such option in the arrow function, but you might try to
play around with the shape package and its various arrowhead options.
library(shape)
plot(1:10)
Arrows(4, 5, 6, 7, lty=2)

HTH,
  Denes
#

        
> On 14-Nov-11 09:57:52, Matthias Gondan wrote:
>> Dear R developers,
    >> 
    >> I want to draw an arrow in a figure with lty=2. The lty
    >> argument also affects the edge of the arrow, which is
    >> unfortunate. Feature or bug?
    >> 
    >> Is there some way to draw an arrow with intact edge,
    >> still with lty=2?
    >> 
    >> Example code:
    >> 
    >> plot(1:10) arrows(4, 5, 6, 7, lty=2)
    >> 
    >> Best wishes, Matthias

    > According to ?arrows, it would seem that there is no
    > provision to draw the arrow shaft and the arrow head using
    > different line types with a single call to arrows().

    > To the extent that this represents the absence of a
    > desirable feature (since you desire it), I would designate
    > it as a bug.

    > It can be done with two calls to arrows(), as follows:

    >   plot(1:10) arrows(4, 5, 6, 7, lty=2, length=0)
    > arrows(5.99, 6.99, 6, 7, lty=1)

Another possibility is to use p.arrows() from package 'sfsmisc'
which draws "nice arrow heads";
and if you like to keep them simple, do *not* fill them :

install.packages("sfsmisc")

require("sfsmisc")

example(arrows) # - show R's standard arrows()

## The example from the p.arrows()  help page:
plot(x,y, main="p.arrows(.)")
p.arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3, fill = "dark blue")

## not filling the arrow heads -- and using  lty :
plot(x,y, main="p.arrows(.)")
p.arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3, lty = 2, fill = NA)


    > Of course, the first could also be done using lines().

    > Ted.