I am trying to plot a spray chart for baseballs in R. I am using Trackman data which does not have regular x and y coordinates like MLB does.
The x variable is directional info that is called "Bearing" and is measured in degrees. It is defined as: The horizontal angle formed by the intersection of the y-axis and a straight line drawn from the plate to the landing spot of the ball.
The Y variable would be "Distance" which is the distance the ball travels and is measured in feet.
The question is how to use Bearing and Distance together to plot where a batted ball lands on the field. Been searching for a long time and really having trouble.
This is the code I have been playing with. Never mind that it creates a rectangle. I have not gotten to figure out how to create a real field yet. Just trying to plot for now. As info - the bearing down the 1B line is 45 degrees the bearing down the 3B line is -45 degrees, and the line directly up the middle would be zero.
ggplot(dfbb, aes(x = Bearing, y = Distance, color = PlayResult)) +
geom_point(alpha = 0.5) +
annotate("rect", xmin = -60, xmax = 60, ymin = 0, ymax = 400, fill = "transparent", color = "black") +
labs(title = "Baseball Spray Chart", x = "Bearing", y = "Distance (ft)")
Any help would be great!