Draws accurate, scaled sports fields in R
Built on ggplot2, so you can layer your own data
Ideal for spray charts, shot charts, heatmaps, and tracking data
Supports multiple sports: baseball, football, soccer, basketball, hockey
Each sport has its own geom_*() function
Fields act as base layers in a ggplot
You add points, heatmaps, or paths on top
Analyze where hits land
Compare hits vs outs
spray_plot <-
geom_baseball("mlb") +
ggplot2::labs(
title = "MLB Baseball Field",
x = 'ft',
y = 'ft'
)+
geom_point(
data = ff,
aes(x = location_x, y = location_y, color = H),
size = 3, alpha = 0.9
) +
scale_colour_manual(values = c("Out" = "red", "Hit" = "blue")) +
coord_fixed(
xlim = c(x_min, x_max),
ylim = c(y_min, y_max)
)sportyR vignette
Drucker, R. (2025). sportyR: Plot Scaled ‘ggplot’ Representations of Sports Playing Surfaces. R package version 2.2.3. sportsdataverse.r-universe.dev
Drucker, R. (2025). Getting Started with sportyR. Vignette and documentation. sportyr.sportsdataverse.org
MLB Advanced Media / Baseball Savant. Statcast Search. baseballsavant.mlb.com/statcast_search
<Graham Medairy>
Email: <Graham_medairy1@baylor.edu>