geom_arrow | R Documentation |
This arrow geom can be used to draw lines adorned with arrow heads or fins. It is useful as an annotation layer to point to or away from other things on the plot. An arrow typically consists of three parts: the arrowhead, the shaft and fins. This geom places arrow heads at the end of a line and fins at the beginning of a line.
geom_arrow(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
arrow_head = arrow_head_wings(),
arrow_fins = NULL,
arrow_mid = NULL,
length = 4,
length_head = NULL,
length_fins = NULL,
length_mid = NULL,
justify = 0,
force_arrow = FALSE,
mid_place = 0.5,
resect = 0,
resect_head = NULL,
resect_fins = NULL,
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
arrow_head , arrow_fins , arrow_mid |
A function call to one of the arrow ornament functions that can determine the shape of the arrow head, fins or middle (interior) arrows. |
length , length_head , length_fins , length_mid |
Determines the size of
the arrow ornaments.
|
justify |
A |
force_arrow |
A |
mid_place |
Sets the location of middle (interior) arrows, when applicable. Can be one of the following:
|
resect , resect_head , resect_fins |
A |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A <Layer>
ggproto object that can be added to a plot.
geom_arrow()
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
arrow_fins
arrow_head
arrow_mid
colour
group
linetype
linewidth
resect_fins
resect_head
stroke_colour
stroke_width
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
Other arrow geoms:
annotate_arrow()
,
geom_arrow_chain()
,
geom_arrow_curve()
,
geom_arrow_segment()
# Setting up a plot
p <- ggplot(whirlpool(), aes(x, y, colour = group)) +
coord_equal()
# A standard arrow
p + geom_arrow()
# Arrows can have varying linewidths
p + geom_arrow(aes(linewidth = arc))
# You can use `length_head` to decouple arrow-head size from linewidth
p + geom_arrow(aes(linewidth = arc), length_head = unit(10, "mm"))
# The arrow head shape can be controlled with the `arrow_head` argument
p + geom_arrow(arrow_head = arrow_head_line(), length_head = unit(10, "mm"))
# This works similarly for the arrow fins
p + geom_arrow(
arrow_fins = arrow_fins_feather(),
length_fins = unit(7, "mm")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.