Description Usage Arguments Value Examples
Draws a soccer pitch as a ggplot object for the purpose of adding layers such as player positions, player trajectories, etc..
1 2 3 4 5 6 7 8 9 |
lengthPitch, widthPitch |
length and width of pitch in metres |
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 |
data |
a default dataset for plotting in subsequent layers; NULL by default |
a ggplot object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(ggplot2)
data(statsbomb)
# transform Statsbomb coordinates to metre units for plotting
my_df <- soccerTransform(statsbomb, method = "statsbomb")
# filter events of interest (France defensive pressure events vs. Argentina)
my_df <- my_df %>%
dplyr::filter(team.name == "France" & type.name == "Pressure")
# add custom layers to soccerPitch base
soccerPitch(data = my_df,
arrow = "r", theme = "grass",
title = "France (vs. Argentina)",
subtitle = "Pressure events") +
geom_point(aes(x = location.x, y = location.y),
col = "blue", alpha = 0.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.