Learn R Programming

soccermatics (version 0.8.4)

soccerPitchFG: Add soccer pitch outlines to an existing ggplot

Description

Draws soccer pitch outlines (with transparent fill) over an existing ggplot object to provide context for heatmaps, passing maps, etc..

Usage

soccerPitchFG(plot, lengthPitch = 105, widthPitch = 68,
  line_col = "black")

Arguments

plot

an existing ggplot object to add layers to.

lengthPitch, widthPitch

numeric, length and width of pitch in metres.

Value

a ggplot object

See Also

soccerPitchBG for a background soccer pitch for the purpose of drawing position maps, 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