baseballr
baseballr copied to clipboard
reconfigure ggspraychart()
I think it is unnecessary. I think it would be cleaner to just define geom_baseball_field()
and let people use the existing ggplot2
functionality.
Maybe I will add this to my pull request...
Or at the very least, have ggspraychart()
take an aes
argument instead of x_value
and y_value
.
Or even just something like this:
spray_chart <- function(...) {
ggplot(...) +
geom_point() + # maybe?
xlim(0,250) +
ylim(-250, 0) +
geom_curve(x = 33, xend = 223, y = -100, yend = -100,
curvature = -.65) +
geom_segment(x=128, xend = 33, y=-208, yend = -100) +
geom_segment(x=128, xend = 223, y=-208, yend = -100) +
geom_curve(x = 83, xend = 173, y = -155, yend = -156,
curvature = -.65, linetype = "dotted") +
coord_fixed()
}
Also, note that some re-centering and translation like this would make these coordinates a lot easier to interpret (https://github.com/beanumber/openWAR/blob/fc626057c215361cc8885be7da8d97888ba48a12/R/GameDay.R#L587)