Description Usage Arguments Value See Also Examples
Multiple arrows to show the distribution of pass angle and distance in zones of the pitch; similar to a radar plot but grouped by pitch location rather than player
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | soccerSpokes(
df,
lengthPitch = 105,
widthPitch = 68,
xBins = 5,
yBins = NULL,
angleBins = 8,
x = "x",
y = "y",
angle = "angle",
minLength = 0.6,
minAlpha = 0.5,
minWidth = 0.5,
col = "black",
legend = TRUE,
arrow = c("none", "r", "l"),
title = NULL,
subtitle = NULL,
theme = c("light", "dark", "grey", "grass"),
plot = NULL
)
|
df |
a dataframe of event data containing fields of start x,y-coordinates, pass distance, and pass angle |
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 |
angleBins |
integer, the number of arrows to draw in each zone of the pitch; for example, a value of 4 clusters has direction vectors up, down, left, and right |
x, y, angle |
names of variables containing pass start x,y-coordinates and angle |
minLength |
numeric, ratio between size of shortest arrow and longest arrow depending on number of events |
minAlpha, minWidth |
numeric, minimum alpha and line width of arrows drawn |
col |
colour of arrows |
legend |
if |
arrow |
adds team direction of play arrow as right ( |
title, subtitle |
adds title and subtitle to plot; NULL by default |
theme |
palette of pitch background and lines, either |
plot |
base plot to add path layer to; NULL by default |
a ggplot object of a heatmap on a soccer pitch
soccerHeatmap
for drawing a heatmap of player position, or soccerFlow
for drawing a single arrow for pass distance and angle per pitch zone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(dplyr)
data(statsbomb)
# transform x,y-coords, filter only France pass events,
# draw flow field showing mean angle, distance of passes per pitch zone
statsbomb %>%
soccerTransform(method = 'statsbomb') %>%
filter(team.name == "France" & type.name == "Pass") %>%
soccerSpokes(xBins=7, yBins=5, angleBins=12, legend=FALSE)
# transform x,y-coords, standarise column names,
# filter only France pass events
my_df <- statsbomb %>%
soccerTransform(method = 'statsbomb') %>%
soccerStandardiseCols(method = 'statsbomb') %>%
filter(team_name == "France" & event_name == "Pass")
# overlay flow field onto heatmap showing proportion of team passes per pitch zone
soccerHeatmap(my_df, xBins=7, yBins=5,
title = "France passing radar") %>%
soccerSpokes(my_df, xBins=7, yBins=5, angleBins=8, legend=FALSE, plot = .)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.