stater_long <- stater %>%
tidyr::pivot_longer(cols = c(unc, state),
names_to = "team",
values_to = "score")
stater_long %>%
ggplot2::ggplot(aes(x = season)) +
ggplot2::geom_step(
data = stater_long %>% filter(team == "unc"),
mapping = aes(y = cumsum(score)),
linewidth = 1,
color = "#56a0d3"
) +
ggplot2::geom_step(
data = stater_long %>% filter(team == "state"),
mapping = aes(y = cumsum(score)),
linewidth = 1,
color = "#CC0000"
) +
ggplot2::annotate(
cfbplotR::GeomCFBlogo,
x = 2017 ,
y = 105,
team = "North Carolina",
height = .095
) +
ggplot2::annotate(
cfbplotR::GeomCFBlogo,
x = 2021 ,
y = 150,
team = "NC State",
height = .095
) +
ggplot2::scale_y_continuous(breaks = seq(0, 165, 15), limits = c(0, 165)) +
ggplot2::scale_x_continuous(breaks = seq(2013, 2022, 1)) +
ggthemes::theme_fivethirtyeight() +
ggplot2::theme(
text = element_text(family = "Arial", size = 14),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown()
) +
labs(
title = "<span style='color:#CC0000'>NC State</span> has more scored more runs (163) \nthan <span style='color:#56a0d3'>North Carolina</span> (151) over the past 31 meetings",
subtitle = "The <span style='color:#56a0d3'>Tar Heels</span> have won 18 of the last 31 games",
caption = "@dadgumboxscores | May 10, 2023 | data via goheels.com",
x = "",
y = "Runs"
) +
annotate(
geom = "text",
x = 2020,
y = 120,
color = "#333333",
label = "COVID",
size = 6,
fontface = 'bold',
family = 'mono'
) -> st_run_plot
# save it
ggplot2::ggsave(
"st_run_plot.png",
st_run_plot,
w = 8.5,
h = 8.5,
dpi = 600,
type = 'cairo'
)
st_run_plot