Learn R Programming

soccermatics (version 0.9.0)

soccerPitch: Plot a soccer pitch ggplot object

Description

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

Usage

soccerPitch(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)

Arguments

lengthPitch, widthPitch

length and width of pitch in metres

fillPitch, colPitch

pitch fill and line colour

grass

if TRUE, uses a more realistic pitch

arrow

optional, adds arrow showing team attack direction as right ('r') or left ('l')

arrow_col

colour of attack direction arrow

lwd

numeric, pitch line width

title, subtitle

optional, adds title and subtitle to plot

Value

a ggplot object

See Also

soccerPitchFG for adding soccer pitch lines to 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
soccerPitch(grass = TRUE) + 
  geom_path(data = dd, aes(x, y))

# }

Run the code above in your browser using DataLab