NL East 2019 Season Records

Data

This plot uses the atl, phi, was, nym and mia data frames of the gcubed package. The original data was obtained from Baseball Reference.

library(gcubed)
head(nleast)
## # A tibble: 6 x 26
##   `Gm#` Date  Tm    HomeAway Opp   WL    wo        R    RA   Inn `W-L`
##   <dbl> <chr> <chr> <chr>    <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr>
## 1     1 Thur… ATL   @        PHI   L     <NA>      4    10    NA 0-1  
## 2     2 Satu… ATL   @        PHI   L     <NA>      6     8    NA 0-2  
## 3     3 Sund… ATL   @        PHI   L     <NA>      1     5    NA 0-3  
## 4     4 Mond… ATL   <NA>     CHC   W     <NA>      8     0    NA 1-3  
## 5     5 Wedn… ATL   <NA>     CHC   W     <NA>      6     4    NA 2-3  
## 6     6 Thur… ATL   <NA>     CHC   W     <NA>      9     4    NA 3-3  
## # … with 15 more variables: Rank <dbl>, Win <chr>, Loss <chr>, Save <chr>,
## #   Time <drtn>, `D/N` <chr>, Attendance <dbl>, Streak <chr>, `Orig.
## #   Scheduled` <lgl>, win_updown <dbl>, games_updown <dbl>, played <dbl>,
## #   wins <dbl>, tot_played <dbl>, tot_wins <dbl>

Code

nleast$Tm <- factor(nleast$Tm, levels = c("ATL", "WSN", "PHI", "NYM", "MIA"))
nlplot <- ggplot(data = nleast, aes(x = `Gm#`, y = win_updown,
                          fill = factor(WL, levels = c("W", "L")))) +
  geom_bar(stat = "identity") +
  facet_wrap(~Tm, ncol = 1) +
  scale_fill_manual(values = c("royalblue", "peachpuff"), name = "") +
  theme_bw() +
  ggtitle("NL East 2019") +
  xlab("Game #") +
  theme(axis.title.y=element_blank(),
        #axis.text.x=element_blank(),
        axis.ticks.x = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        plot.title = element_text(size = 16, face = "bold", hjust = 0.5))

nlplot