0

I would like to use the arrows function in R to plot different shaped arrow heads onto a network graph (I'm using NetworkD3 and iGraph which both use the arrows function). This works great at the moment but I would like some to be normal triangular arrow heads and others to be 'T' shaped arrow heads. The arrows function says:

arrows(x0, y0, x1 = x0, y1 = y0, length = 0.25, angle = 30,
       code = 2, col = par("fg"), lty = par("lty"),
       lwd = par("lwd"), …)

code = integer code, determining kind of arrows to be drawn. If code = 1 an arrowhead is drawn at (x0[i], y0[i]) and if code = 2 an arrowhead is drawn at (x1[i], y1[i]). If code = 3 a head is drawn at both ends of the arrow. Unless length = 0, when no head is drawn.

Currently I'm using code to determine what direction the arrows are drawn in, all well and good, but I was wondering if it was possible to change code = 1 to result in a "T" shaped arrow head, rather than an arrow going in the opposite direction.

I tried looking for packages that might change this but I had no luck and I couldn't seem to figure out how to edit the arrows function by myself, if anyone could give me some pointers that would be wonderful!

bio_beans
  • 1
  • 1
  • Can you provide a minimal code example of your problem? – Blind0ne May 13 '20 at 16:42
  • What is T shaped arrow? Do you mean `arrows(..., angle = 90)`? – Darren Tsai May 13 '20 at 16:45
  • As in, the arrow point looks like a 'T' rather than a triangle. Like an arrow with a blunt end, or a flat line perpendicular to the main arrow line? Can ```angle = 90``` conditionally plot arrows with a flat point (or no point)? – bio_beans May 13 '20 at 18:02
  • Also, sorry I can't supply a minimal code example because the arrow() function is working like normal and the network plotting isn't relevant. The code is as written above, when I use arrows in my network I supply a column with either 0, 1, 2 or 3 which determines the arrow direction, however I want to change ```code = 1``` parameter in arrows() to result in a blunt ended arrow rather than a backwards arrow, which you get if you plot an igraph object or networkD3 graph. I want to know how to change this within arrows(). – bio_beans May 13 '20 at 18:08
  • `networkD3` does not use `arrows()` – CJ Yetman May 13 '20 at 21:54
  • Oh. I was under the impression that "arrows = logical value that can be enabled", was from the R graphics package: ```forceNetwork(Links, Nodes, Source, Target, Value, NodeID, Nodesize, Group, height = NULL, width = NULL, colourScale = JS("d3.scaleOrdinal(d3.schemeCategory20);"), fontSize = 7, fontFamily = "serif", linkDistance = 50, radiusCalculation = JS(" Math.sqrt(d.nodesize)+6"), charge = -30, linkColour = "#666", opacity = 0.6, zoom = FALSE, legend = FALSE, arrows = FALSE, bounded = FALSE, opacityNoHover = 0, clickAction = NULL)``` – bio_beans May 14 '20 at 09:27
  • Nope, `networkD3` arrows are generated on the JavaScript side. – CJ Yetman May 14 '20 at 13:24

0 Answers0