soccerPassmap: Draw a passing network using StatsBomb data

Description Usage Arguments Examples

View source: R/soccerPassmap.R

Description

Draw an undirected passing network of completed passes on pitch from StatsBomb data. Nodes are scaled by number of successful passes; edge width is scaled by number of successful passes between each node pair. Only passes made until first substition shown (ability to specify custom minutes will be added soon). Total number of passes attempted and percentage of completed passes shown. Compatability with other (non-StatsBomb) shot data will be added soon.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
soccerPassmap(
  df,
  lengthPitch = 105,
  widthPitch = 68,
  minPass = 3,
  fill = "red",
  col = "black",
  edgeAlpha = 0.6,
  edgeCol = NULL,
  label = TRUE,
  shortNames = TRUE,
  maxNodeSize = 30,
  maxEdgeSize = 30,
  labelSize = 4,
  arrow = c("none", "r", "l"),
  theme = c("light", "dark", "grey", "grass"),
  title = NULL
)

Arguments

df

dataframe containing x,y-coordinates of player passes

lengthPitch, widthPitch

numeric, length and width of pitch, in metres

minPass

minimum number of passes between players for edge to be drawn

fill, col

fill and border colour of nodes

edgeAlpha

transparency of edge lines, from 0 - 1. Defaults to 0.6 so overlapping edges are visible.

edgeCol

colour of edge lines. Default is complementary to theme colours.

label

boolean, draw labels

shortNames

shorten player names to display last name as label

maxNodeSize

maximum size of nodes

maxEdgeSize

maximum width of edge lines

labelSize

size of player name labels

arrow

optional, adds team direction of play arrow as right ('r') or left ('l')

theme

draws a light, dark, grey, or grass coloured pitch

title

adds custom title to plot. Defaults to team name.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# France vs. Argentina, minimum of three passes
library(dplyr)
data(statsbomb)

# transform x,y-coords,
# Argentina pass map until first substituton with transparent edges
statsbomb %>% 
  soccerTransform(method='statsbomb') %>% 
  filter(team.name == "Argentina") %>% 
  soccerPassmap(fill = "lightblue", arrow = "r",
                title = "Argentina (vs France, 30th June 2018)")

# transform x,y-coords,
# France pass map until first substitution with opaque edges
statsbomb %>% 
  filter(team.name == "France") %>% 
  soccerTransform(method='statsbomb') %>% 
  soccerPassmap(fill = "blue", minPass = 3,
                maxEdgeSize = 30, edgeCol = "grey40", edgeAlpha = 1,
                title = "France (vs Argentina, 30th June 2018)")

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