Learn Python and AI for free! One week only. No credit card needed.
Ends in:
Draws a soccer pitch as a ggplot object for the purpose of adding layers such as player positions, player trajectories, etc..
soccerPitchBG(lengthPitch = 105, widthPitch = 68, fillPitch = "white",
colPitch = "grey60", grass = FALSE, arrow = c("none", "r", "l"),
arrow_col = "default", lwd = 0.5, title = NULL, subtitle = NULL)
length and width of pitch in metres
pitch fill and line colour
if TRUE
, uses a more realistic pitch
optional, adds arrow showing team attack direction as right ('r'
) or left ('l'
)
colour of attack direction arrow
numeric, pitch line width
optional, adds title and subtitle to plot
a ggplot object
soccerPitchFG
for adding soccer pitch lines to an existing ggplot object
# NOT RUN {
# get x,y-coords of player #8 during first 10 minutes
data(tromso)
dd <- subset(tromso, id == 9)[1:1200,]
# draw player path on pitch
soccerPitchBG(grass = TRUE) +
geom_path(data = dd, aes(x, y))
# }
Run the code above in your browser using DataLab