grob_arrow {ggarrow} | R Documentation |
Arrow grob
Description
Creates a graphical object that draws arrows. An arrow typically consists of three parts: the arrowhead, the shaft and fins. Relative to how an arrow is drawn from coordinates, these three parts describe the end, middle and beginning of an arrow line.
Usage
grob_arrow(
x = unit(c(0, 1), "npc"),
y = unit(c(0, 1), "npc"),
id = NULL,
id.lengths = NULL,
arrow_head = arrow_head_wings(),
arrow_fins = NULL,
arrow_mid = NULL,
length_head = unit(5, "mm"),
length_fins = NULL,
length_mid = NULL,
justify = 0,
shaft_width = unit(1, "mm"),
mid_place = 0.5,
resect = unit(0, "mm"),
resect_fins = NULL,
resect_head = NULL,
force_arrow = FALSE,
default.units = "mm",
name = NULL,
gp = gpar(),
vp = NULL
)
Arguments
x |
A numeric vector or unit object specifying x-values. |
y |
A numeric vector or unit object specifying y-values. |
id |
A numeric vector used to separate locations in |
id.lengths |
A numeric vector used to separate locations in |
arrow_head , arrow_fins , arrow_mid |
A |
length_head , length_fins , length_mid |
A |
justify |
A |
shaft_width |
A |
mid_place |
Sets the location of middle (interior) arrows, when applicable. Can be one of the following:
|
resect , resect_fins , resect_head |
A |
force_arrow |
A |
default.units |
A string indicating the default units to use
if |
name |
A character identifier. |
gp |
An object of class |
vp |
A Grid viewport object (or NULL). |
Value
A <arrow_path>
graphical object.
Examples
requireNamespace("grid")
# Creating an arrow
arrow <- grob_arrow(
x = unit(c(0.2, 0.5, 0.8, 0.2, 0.5, 0.8), "npc"),
y = unit(c(0.2, 0.8, 0.2, 0.8, 0.2, 0.8), "npc"),
id.lengths = c(3, 3),
arrow_head = arrow_head_wings(),
arrow_fins = arrow_fins_feather(),
length_fins = 8,
shaft_width = 1,
gp = grid::gpar(fill = c("dodgerblue", "tomato"), col = "black")
)
# Drawing the arrow
grid::grid.newpage(); grid::grid.draw(arrow)