fc_annotate: Pitch annotations

Description Usage Arguments Details References Examples

Description

These functions add pitch annotations to better visualize match-event data. They utilize a series of geom annotations and can be customized by color and fill. These annotations integrate with coord_flip().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
fc_annotate_pitch(
  dimensions = c(105, 70),
  palette = "gw",
  color = NULL,
  fill = NULL,
  coord_flip = FALSE
)

fc_annotate_arrow(
  x,
  y,
  arrow_length = 20,
  palette = "gw",
  color = NULL,
  coord_flip = FALSE
)

Arguments

dimensions

A numeric vector of length two for pitch dimensions. The default of (105, 70) is close to the regulation size of the EPL.

palette

A color palette character vector of length one, often paired with a corresponding theme function. Options include: "bw", "classic", "dark", "gw", "smurf", "wc".

color

A color name or hex character value. This will override any set palette.

fill

A color name or hex character value. This will override any set palette.

coord_flip

A logical vector of length one. Set to TRUE to use with coord_flip().

x

The x location for the arrow's position.

y

The y location for the arrow's position.

arrow_length

The total length of the arrow.

Details

fc_annotate_pitch()

Adds a soccer pitch with all field markings.

fc_annotate_arrow()

Adds an arrow indicating the direction of attack. A text label classifying this direction as "east" is also included.

References

Pappalardo, L., Cintia, P., Rossi, A. et al. A public data set of spatio-temporal match events in soccer competitions. Sci Data 6, 236 (2019). https://doi.org/10.1038/s41597-019-0247-7

All public Wyscout data is available at https://figshare.com/collections/Soccer_match_event_dataset/4415000/2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# load ggplot2
library(ggplot2)

ggplot() +
  fc_annotate_pitch() +
  theme_void()

ggplot() +
  fc_annotate_pitch() +
  fc_annotate_arrow(x = 52.5, y = -5) +
  theme_void()

ggplot() +
  fc_annotate_pitch(palette = "smurf") +
  fc_annotate_arrow(x = 52.5, y = -5, palette = "smurf") +
  fc_theme_smurf()

ggplot() +
  fc_annotate_pitch(palette = "smurf", coord_flip = TRUE) +
  fc_annotate_arrow(x = 52.5, y = -5, palette = "smurf", coord_flip = TRUE) +
  coord_flip() +
  fc_theme_smurf()

shawnsanto/scoutr documentation built on Feb. 27, 2021, 1:02 p.m.