R/direction_label.R
direction_label.Rd
Adds an arrow indicating the direction of play to a ggplot plot
direction_label(
x_label = 50,
y_label = -3,
label_length = 20,
colour = "dimgray",
linewidth = 0.5,
linetype = "solid",
text_size = 3
)
x position of the centre of the arrow on the plot
y position of the arrow on the plot
length of arrow (in x axis units)
colour of the arrow and text
thickness of the arrow
linetype of the arrow
size of label text (passed onto geom_text
)
list of ggplot layers to be added to a ggplot plot
library(ggplot2)
shots_data <- data.frame(x = c(90, 85, 82, 78, 83),
y = c(43, 40, 52, 56, 44))
p <- ggplot(shots_data, aes(x = x, y = y)) +
annotate_pitch() +
geom_point()
# Add direction of play label
p + direction_label()