View source: R/geom_arrow_chain.R
| geom_arrow_chain | R Documentation |
An arrow chains connects a set of coordinates with a sequence of arrows. The
geom_arrow_chain() function can be useful to connect observations in a
directed manner.
geom_arrow_chain(
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 = 1,
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_segment() understands the following aesthetics. Required aesthetics are displayed in bold and defaults are displayed for optional aesthetics:
| • | x | |
| • | y | |
| • | xend or yend | |
| • | alpha | → NA |
| • | arrow_fins | → NULL |
| • | arrow_head | → NULL |
| • | arrow_mid | → NULL |
| • | colour | → via theme() |
| • | group | → inferred |
| • | linetype | → via theme() |
| • | linewidth | → via theme() |
| • | linewidth_fins | → NULL |
| • | linewidth_head | → NULL |
| • | resect_fins | → NULL |
| • | resect_head | → NULL |
| • | stroke_colour | → via theme() |
| • | stroke_width | → via theme() |
The linewidth_fins and linewidth_head inherit from linewidth. They can be used to seperately control the start- and end-width.
Learn more about setting these aesthetics in vignette("ggplot2-specs").
Other arrow geoms:
annotate_arrow(),
geom_arrow(),
geom_arrow_curve(),
geom_arrow_segment()
# Setup dummy data
t <- seq(0, 2 * pi, length.out = 11)
l <- rep(c(1, 0.4), length.out = 11)
df <- data.frame(
x = cos(t) * l,
y = sin(t) * l,
size = l + 0.4
)
p <- ggplot(df, aes(x, y, size = size)) +
geom_point(colour = 2) +
coord_equal()
# An arrow chains adapts to the `size` aesthetic to go nicely with points
p + geom_arrow_chain()
# Without arrowhead, it is similar to a `type = 'b'` base R plot
p + geom_arrow_chain(arrow_head = NULL)
# To widen the gap, one can increase the `resect` parameter
p + geom_arrow_chain(resect = 5)
# To ignore the points, set `resect` and `size` to 0
p + geom_arrow_chain(size = 0, resect = 0)
# Linewidths will be interpolated across arrows
p + geom_arrow_chain(aes(linewidth = seq_along(x)))
# Alternatively, we can set them seperately for starts and ends
p + geom_arrow_chain(linewidth_fins = 0, linewidth_head = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.