soccerShotmap: Draw an individual, team, or two team shotmap using StatsBomb...

Description Usage Arguments Value Examples

View source: R/soccerShotmap.R

Description

If df contains two teams, draws a shotmap of each team at either end of a full pitch. If df contains one or more players from a single team, draws a vertical half pitch. Currently only works with StatsBomb data but compatability with other (non-StatsBomb) shot data will be added soon.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
soccerShotmap(
  df,
  lengthPitch = 105,
  widthPitch = 68,
  homeTeam = NULL,
  adj = TRUE,
  n_players = 0,
  size_lim = c(2, 15),
  title = NULL,
  subtitle = NULL,
  theme = c("light", "dark", "grey", "grass")
)

Arguments

df

dataframe containing x,y-coordinates of player passes

lengthPitch, widthPitch

length and width of pitch, in metres

homeTeam

if df contains two teams, the name of the home team to be displayed on the left hand side of the pitch. If NULL, infers home team as the team of the first event in df.

adj

adjust xG using conditional probability to account for multiple shots per possession

n_players

number of highest xG players to display

size_lim

minimum and maximum size of points, c(min, max)

title, subtitle

optional, adds title and subtitle to half pitch plot. Title defaults to scoreline and team identity when two teams are defined in df.

theme

draws a light, dark, grey, or grass coloured pitch with appropriate point colours

Value

a ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(statsbomb)

# shot map of two teams on full pitch
statsbomb %>%
  soccerTransform(method='statsbomb') %>% 
  soccerShotmap(theme = "gray")

# shot map of one player on half pitch
statsbomb %>% 
  dplyr::filter(player.name == "Antoine Griezmann") %>% 
  soccerTransform(method='statsbomb') %>% 
  soccerShotmap(theme = "grass",
                title = "Antoine Griezmann", 
                subtitle = "vs. Argentina, World Cup 2018")

JoGall/soccermatics documentation built on Aug. 12, 2021, 1:20 p.m.