Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -518,8 +518,8 @@ catcher_process_dataset <- function(df) {
|
|
| 518 |
mutate(
|
| 519 |
PitchCall = trimws(gsub("\\s+", "", PitchCall)),
|
| 520 |
in_zone = as.integer(!is.na(PlateLocSide) & !is.na(PlateLocHeight) &
|
| 521 |
-
PlateLocSide >= -0.
|
| 522 |
-
PlateLocHeight >= 1.
|
| 523 |
is_swing = as.integer(PitchCall %in% SWING_CALLS),
|
| 524 |
StrikeZoneIndicator = in_zone,
|
| 525 |
StolenStrike = as.integer(in_zone == 0 & PitchCall %in% STRIKE_CALLS),
|
|
@@ -559,7 +559,7 @@ catcher_create_framing_plots <- function(catcher_data, catcher_name) {
|
|
| 559 |
)
|
| 560 |
|
| 561 |
# Define the strike zone boundaries (matching in_zone calculation)
|
| 562 |
-
zone <- data.frame(xmin = -0.
|
| 563 |
|
| 564 |
make_plot <- function(data, title, show_legend = FALSE){
|
| 565 |
if (!nrow(data)) return(ggplot2::ggplot() + ggplot2::theme_void() + ggplot2::ggtitle(title))
|
|
@@ -572,11 +572,11 @@ catcher_create_framing_plots <- function(catcher_data, catcher_name) {
|
|
| 572 |
fill = NA, color = "black", size = 0.5
|
| 573 |
) +
|
| 574 |
# home plate (your original, lowered)
|
| 575 |
-
ggplot2::annotate("segment", x=-0.
|
| 576 |
-
ggplot2::annotate("segment", x=-0.
|
| 577 |
-
ggplot2::annotate("segment", x= 0.
|
| 578 |
-
ggplot2::annotate("segment", x=-0.
|
| 579 |
-
ggplot2::annotate("segment", x= 0.
|
| 580 |
# pitches
|
| 581 |
ggplot2::geom_point(ggplot2::aes(color = TaggedPitchType), size = 3, alpha = 0.95, na.rm = TRUE) +
|
| 582 |
ggplot2::scale_color_manual(values = pitch_colors, na.value = "grey60", name = "Pitch Type") +
|
|
|
|
| 518 |
mutate(
|
| 519 |
PitchCall = trimws(gsub("\\s+", "", PitchCall)),
|
| 520 |
in_zone = as.integer(!is.na(PlateLocSide) & !is.na(PlateLocHeight) &
|
| 521 |
+
PlateLocSide >= -0.83 & PlateLocSide <= 0.83 &
|
| 522 |
+
PlateLocHeight >= 1.5 & PlateLocHeight <= 3.38),
|
| 523 |
is_swing = as.integer(PitchCall %in% SWING_CALLS),
|
| 524 |
StrikeZoneIndicator = in_zone,
|
| 525 |
StolenStrike = as.integer(in_zone == 0 & PitchCall %in% STRIKE_CALLS),
|
|
|
|
| 559 |
)
|
| 560 |
|
| 561 |
# Define the strike zone boundaries (matching in_zone calculation)
|
| 562 |
+
zone <- data.frame(xmin = -0.83, xmax = 0.83, ymin = 1.5, ymax = 3.38)
|
| 563 |
|
| 564 |
make_plot <- function(data, title, show_legend = FALSE){
|
| 565 |
if (!nrow(data)) return(ggplot2::ggplot() + ggplot2::theme_void() + ggplot2::ggtitle(title))
|
|
|
|
| 572 |
fill = NA, color = "black", size = 0.5
|
| 573 |
) +
|
| 574 |
# home plate (your original, lowered)
|
| 575 |
+
ggplot2::annotate("segment", x=-0.83, y=0.05, xend=0.83, yend=0.05, size=0.5, color="black") +
|
| 576 |
+
ggplot2::annotate("segment", x=-0.83, y=0.20, xend=-0.83, yend=0.05, size=0.5, color="black") +
|
| 577 |
+
ggplot2::annotate("segment", x= 0.83, y=0.20, xend= 0.83, yend=0.05, size=0.5, color="black") +
|
| 578 |
+
ggplot2::annotate("segment", x=-0.83, y=0.20, xend=0, yend=0.40, size=0.5, color="black") +
|
| 579 |
+
ggplot2::annotate("segment", x= 0.83, y=0.20, xend=0, yend=0.40, size=0.5, color="black") +
|
| 580 |
# pitches
|
| 581 |
ggplot2::geom_point(ggplot2::aes(color = TaggedPitchType), size = 3, alpha = 0.95, na.rm = TRUE) +
|
| 582 |
ggplot2::scale_color_manual(values = pitch_colors, na.value = "grey60", name = "Pitch Type") +
|