Description Usage Arguments Value See Also Examples
View source: R/soccerPitchHalf.R
Adds soccer pitch outlines (with transparent fill) to an existing ggplot object (e.g. heatmaps, passing maps, 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 ( |
theme |
palette of pitch background and lines, either |
title, subtitle |
adds title and subtitle to plot; NULL by default |
data |
a default dataset for plotting in subsequent layers; NULL by default |
a ggplot object
soccerShotmap
for plotting a shotmap on a half pitch for a single player or soccerPitch
for drawing a full size soccer pitch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(ggplot2)
library(dplyr)
data(statsbomb)
# normalise data, get non-penalty shots for France,
# add boolean variable 'goal' for plotting
my_df <- statsbomb %>%
soccerTransform(method = 'statsbomb') %>%
filter(team.name == "France" &
type.name == "Shot" &
shot.type.name != 'penalty') %>%
mutate(goal = as.factor(if_else(shot.outcome.name == "Goal", 1, 0)))
soccerPitchHalf(data = my_df, theme = 'light') +
geom_point(aes(x = location.y, y = location.x,
size = shot.statsbomb_xg, colour = goal),
alpha = 0.7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.