Learn R Programming

soccermatics (version 0.9.0)

soccerPitchFG: Helper function to add soccer pitch outlines to an existing ggplot object

Description

Adds soccer pitch outlines (with transparent fill) to an existing ggplot object (e.g. heatmaps, passing maps, etc..)

Usage

soccerPitchFG(plot, lengthPitch = 105, widthPitch = 68,
  colPitch = "black", arrow = c("none", "r", "l"), arrow_col = "black",
  lwd = 0.5, title = NULL, subtitle = NULL)

Arguments

plot

an existing ggplot object to add pitch lines to

lengthPitch, widthPitch

length and width of pitch in metres

colPitch

pitch fill and line colour

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

soccerPitch for plotting a soccer pitch for the purpose of drawing over event data, average position, player trajectories, etc..

Examples

Run this code
# NOT RUN {
data(tromso)
# draw heatmap of player #9's position
p <- soccerHeatmap(subset(tromso, id == 8), bins = 15, lengthPitch = 105, widthPitch = 68)
# add pitch lines to plot
soccerPitchFG(p, lengthPitch = 105, widthPitch = 68)

# }

Run the code above in your browser using DataLab