Closed discoleo closed 2 years ago
#### Arrow T #### #' @export arrowT = function(x, y, d=0.2, lwd=1, d.head=c(d, -d), d.lines=0, h.lwd=lwd, col="red", scale=1, join=0) { slope = compute_slope(x, y); ### Head if(is.list(d.head)) { ahead = lapply(seq(length(d.head)), function(id) { arrowHeadT(x[2], y[2], slope=slope, dV=d.head[[id]], scale=scale) }); ahead$lwd = h.lwd; } else { ahead = list(arrowHeadT(x[2], y[2], slope=slope, dV=d.head, scale=scale), lwd = h.lwd); } ### ArrowTail arrow = arrowTail(x, y, d.lines=d.lines, lwd=lwd, slope=slope); ### Full Arrow lst = list(Arrow=arrow, Head=ahead); class(lst) = c("arrow", "list"); # Plot lines: lines(lst, col=col); invisible(lst); }
##### T Shape ArrowHead ##### x = c(0, 6); y = c(1, 6); plot.base() arrowT(x, y, d=-1, lwd=2); arrowT(c(x[1], 5), c(y[1], y[1]), d=-1, lwd=2); arrowT(c(x[1], x[1]), c(y[1], 5), d=-1, lwd=2); ### Discontinuous T x = c(0, 6); y = c(1, 6); d.head = list(c(0.2, 0.7), c(-0.2, -0.7)) plot.base() arrowT(x, y, d.head=d.head, lwd=2); arrowT(c(x[1], 5), c(y[1], y[1]), d.head=d.head, lwd=2); arrowT(c(x[1], x[1]), c(y[1], 5), d.head=d.head, lwd=2);
Implemented
arrowT: Improved functionality + Join
arrowT
Tests