Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -4066,7 +4066,6 @@ create_count_usage_plot <- function(data, pitcher_name, pitch_colors) {
|
|
| 4066 |
|
| 4067 |
ggplot(plot_df, aes(x = 1, y = percentage, fill = TaggedPitchType)) +
|
| 4068 |
geom_bar(width = 1, stat = "identity", color = "white") +
|
| 4069 |
-
geom_text(aes(y = label_pos, label = pct_label), size = 3) +
|
| 4070 |
coord_polar(theta = "y", start = 0) +
|
| 4071 |
facet_grid(BatterSide ~ count, labeller = label_value, drop = FALSE) +
|
| 4072 |
ggtitle("Count Usage") +
|
|
@@ -4245,12 +4244,36 @@ add_team_logo <- function(logo_path, x, y, width, height) {
|
|
| 4245 |
create_advanced_pitcher_pdf <- function(game_df, pitcher_name, output_file, logo_dir = "logos") {
|
| 4246 |
if (length(dev.list()) > 0) try(dev.off(), silent = TRUE)
|
| 4247 |
|
| 4248 |
-
|
| 4249 |
-
|
| 4250 |
-
|
| 4251 |
-
|
| 4252 |
-
|
| 4253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4254 |
|
| 4255 |
.text_on_fill <- function(hex) {
|
| 4256 |
if (is.na(hex) || !nzchar(hex)) return("black")
|
|
|
|
| 4066 |
|
| 4067 |
ggplot(plot_df, aes(x = 1, y = percentage, fill = TaggedPitchType)) +
|
| 4068 |
geom_bar(width = 1, stat = "identity", color = "white") +
|
|
|
|
| 4069 |
coord_polar(theta = "y", start = 0) +
|
| 4070 |
facet_grid(BatterSide ~ count, labeller = label_value, drop = FALSE) +
|
| 4071 |
ggtitle("Count Usage") +
|
|
|
|
| 4244 |
create_advanced_pitcher_pdf <- function(game_df, pitcher_name, output_file, logo_dir = "logos") {
|
| 4245 |
if (length(dev.list()) > 0) try(dev.off(), silent = TRUE)
|
| 4246 |
|
| 4247 |
+
pitch_colors <- c(
|
| 4248 |
+
"Fastball" = "#3465cb",
|
| 4249 |
+
"Four-Seam" = "#3465cb",
|
| 4250 |
+
"FourSeamFastBall" = "#3465cb",
|
| 4251 |
+
"4-Seam Fastball" = "#3465cb",
|
| 4252 |
+
"FF" = "#3465cb",
|
| 4253 |
+
"Sinker" = "#e5e501",
|
| 4254 |
+
"TwoSeamFastBall" = "#e5e501",
|
| 4255 |
+
"Two-Seam" = "#e5e501",
|
| 4256 |
+
"2-Seam Fastball" = "#e5e501",
|
| 4257 |
+
"SI" = "#e5e501",
|
| 4258 |
+
"Slider" = "#65aa02",
|
| 4259 |
+
"SL" = "#65aa02",
|
| 4260 |
+
"Sweeper" = "#dc4476",
|
| 4261 |
+
"SW" = "#dc4476",
|
| 4262 |
+
"Curveball" = "#d73813",
|
| 4263 |
+
"CB" = "#d73813",
|
| 4264 |
+
"Knuckle Curve" = "#d73813",
|
| 4265 |
+
"KC" = "#d73813",
|
| 4266 |
+
"ChangeUp" = "#980099",
|
| 4267 |
+
"Changeup" = "#980099",
|
| 4268 |
+
"CH" = "#980099",
|
| 4269 |
+
"Splitter" = "#23a999",
|
| 4270 |
+
"FS" = "#23a999",
|
| 4271 |
+
"SP" = "#23a999",
|
| 4272 |
+
"Cutter" = "#ff9903",
|
| 4273 |
+
"FC" = "#ff9903",
|
| 4274 |
+
"Slurve" = "#9370DB",
|
| 4275 |
+
"Other" = "gray50"
|
| 4276 |
+
)
|
| 4277 |
|
| 4278 |
.text_on_fill <- function(hex) {
|
| 4279 |
if (is.na(hex) || !nzchar(hex)) return("black")
|