| ggpitchzone | R Documentation |
Plots pitch locations from the catcher's perspective with the batter's
strike zone overlaid, from Statcast pitch data as returned by
statcast_search() or mlb_pbp() (the latter via its
pitchData.coordinates.* columns renamed to plate_x / plate_z).
Colors default to Baseball Savant's pitch-type palette via
statcast_pitch_colors().
ggpitchzone(
data,
x_value = "plate_x",
y_value = "plate_z",
color_value = "pitch_type",
sz_top = "sz_top",
sz_bot = "sz_bot",
point_alpha = 0.6,
point_size = 2
)
data |
A data frame of pitch data containing plate-crossing coordinates and strike-zone bounds. |
x_value |
Column with the horizontal plate-crossing coordinate in
feet (catcher's perspective). Defaults to |
y_value |
Column with the vertical plate-crossing coordinate in feet.
Defaults to |
color_value |
Categorical column to color points by, as a string.
Defaults to |
sz_top |
Column with the batter's strike-zone top (feet). Defaults to
|
sz_bot |
Column with the batter's strike-zone bottom (feet). Defaults
to |
point_alpha |
Alpha for the pitch points. Defaults to |
point_size |
Size of the pitch points. Defaults to |
A ggplot2 object: pitch locations from the catcher's perspective with the strike zone drawn as a rectangle.
try({
pitches <- statcast_search("2024-06-01", "2024-06-01")
ggpitchzone(pitches)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.