Learn R Programming

soccermatics (version 0.8.4)

soccerPitchBG: Draw a soccer pitch.

Description

Draws a soccer pitch as a ggplot object for the purpose of adding layers such as player positions, player trajectories, etc..

Usage

soccerPitchBG(lengthPitch = 105, widthPitch = 68, grass = FALSE,
  line_col = "black")

Arguments

lengthPitch, widthPitch

numeric, length and width of pitch in metres.

grass

if TRUE, draws pitch background in green and lines in white. If FALSE, draws pitch background in white and lines in black.

line_col

colour of pitch lines

Value

a ggplot object

See Also

soccerPitchFG for drawing a soccer pitch as foreground over an existing ggplot object

Examples

Run this code
# 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(lengthPitch = 105, widthPitch = 68, grass = TRUE) + 
  geom_path(data = dd, aes(x, y), lwd = 2)

# }

Run the code above in your browser using DataLab