Learn R Programming

diagram (version 1.6.5)

bentarrow: adds 2-segmented arrow between two points

Description

Connects two points with 2 segments (default = horizontal-vertical) and adds an arrowhead on (one of) the segments and at a certain distance.

Usage

bentarrow(from, to, lwd = 2, lty = 1, lcol = "black", arr.col = lcol, 
          arr.side = 2, arr.pos = 0.5, path = "H", ...)

Arguments

from

coordinates (x,y) of the point *from* which to draw arrow.

to

coordinates (x,y) of the point *to* which to draw arrow.

lwd

line width.

lty

line type.

lcol

line color.

arr.col

arrowhead color.

arr.side

segment number on which arrowhead is drawn (1,2).

arr.pos

relative position of arrowhead on segment on which arrowhead is drawn.

path

first segment to be drawn (V=Vertical, H=Horizontal).

...

other arguments passed to function straightarrow.

Value

coordinates (x,y) where arrowhead is drawn

Details

a two-segmented arrow is drawn between two points '(from, to)'

how the segments are drawn is set with path which can take on the values:

  • H: (horizontal): first left or right, then vertical.

  • V: (vertical) : first down- or upward, then horizontal.

The segment(s) on which the arrow head is drawn is set with arr.side, which is one or more values in (1, 2)

The position of the arrowhead on the segment on which it is drawn, is set with arr.pos, a value between 0(start of segment) and 1 (end of segment).

The type of the arrowhead is set with arr.type which can take the values:

  • "none" : skips the drawing of arrows.

  • "simple" : uses comparable R function arrows.

  • "triangle": uses filled triangle.

  • "curved" : draws arrowhead with curved edges.

  • "circle" : draws circular head.

  • "ellipse" : draws ellepsoid head.

  • "T" : draws T-shaped (blunt) head.

The size of the arrow head can be specified with the arguments arr.length and arr.width.

See Arrowhead from package shape for details on arrow head.

See Also

straightarrow, segmentarrow, curvedarrow, selfarrow, treearrow, splitarrow,

arrows: the comparable R function,

Arrows: more complicated arrow function from package shape.

Examples

Run this code
# NOT RUN {
openplotmat(main = "bentarrow")

pos <- cbind( A <- seq(0.1, 0.9, by = 0.2), rev(A))

text(pos, LETTERS[1:5], cex = 2)

for (i in 1:4) 
  bentarrow(from = pos[i,] + c(0.05, 0), to = pos[i+1,] + c(0, 0.05),
            arr.pos = 1, arr.adj = 1)

for (i in 1:2) 
  bentarrow(from = pos[i,] + c(0.05, 0), to = pos[i+1, ] + c(0, 0.05),
            arr.pos = 0.5, path = "V", lcol = "lightblue", 
            arr.type = "triangle")

bentarrow(from = pos[3, ] + c(0.05, 0), to = pos[4, ] + c(0, 0.05),
          arr.pos = 0.7, arr.side = 1, path = "V", lcol = "darkblue")

bentarrow(from = pos[4, ] + c(0.05, 0), to = pos[5, ] + c(0, 0.05),
          arr.pos = 0.7, arr.side = 1:2, path = "V", lcol = "blue")
# }

Run the code above in your browser using DataLab