Description Usage Arguments Details Value Examples
View source: R/soccerHeatmap.R
Draws a heatmap showing player position frequency in each area of the pitch and adds soccer pitch outlines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  | 
df | 
 dataframe containing x,y-coordinates of player position  | 
lengthPitch, widthPitch | 
 numeric, length and width of pitch in metres.  | 
xBins, yBins | 
 integer, the number of horizontal (length-wise) and vertical (width-wise) bins the soccer pitch is to be divided up into. If no value for   | 
kde | 
 use kernel density estimates for a smoother heatmap; FALSE by default  | 
arrow | 
 adds team direction of play arrow as right (  | 
colLow, colHigh | 
 character, colours for the low and high ends of the heatmap gradient; white and red respectively by default  | 
title, subtitle | 
 adds title and subtitle to plot; NULL by default  | 
x, y | 
 name of variables containing x,y-coordinates  | 
uses ggplot2::geom_bin2d to map 2D bin counts
a ggplot object of a heatmap on a soccer pitch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  | library(dplyr)
# tracking data heatmap with 21x5 zones(~5x5m)
data(tromso)
tromso %>% 
  filter(id == 8) %>% 
  soccerHeatmap(xBins = 10)
# transform x,y-coords, filter only France pressure events,
# heatmap with 6x3 zones
data(statsbomb)
statsbomb %>%
  soccerTransform(method='statsbomb') %>% 
  filter(type.name == "Pressure" & team.name == "France") %>% 
  soccerHeatmap(x = "location.x", y = "location.y",
                xBins = 6, yBins = 3, arrow = "r", 
                title = "France (vs Argentina, 30th June 2016)", 
                subtitle = "Defensive pressure heatmap")
# transform x,y-coords, standardise column names,
# filter player defensive actions, plot kernel density estimate heatmap
statsbomb %>%
  soccerTransform(method='statsbomb') %>% 
  soccerStandardiseCols() %>% 
  filter(event_name %in% c("Duel", "Interception", "Clearance", "Block") &
         player_name == "Samuel Yves Umtiti") %>%
  soccerHeatmap(kde = TRUE, arrow = "r",
                title = "Umtiti (vs Argentina, 30th June 2016)",
                subtitle = "Defensive actions heatmap")
                
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.