baseballr icon indicating copy to clipboard operation
baseballr copied to clipboard

reconfigure ggspraychart()

Open beanumber opened this issue 6 years ago • 3 comments

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...

beanumber avatar Jun 13 '18 15:06 beanumber

Or at the very least, have ggspraychart() take an aes argument instead of x_value and y_value.

beanumber avatar Jun 13 '18 16:06 beanumber

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()
}

beanumber avatar Jun 13 '18 16:06 beanumber

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)

beanumber avatar Jun 13 '18 16:06 beanumber