Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OTStats/c381bb28947d5b75a326ab659f8a9dc0 to your computer and use it in GitHub Desktop.
Save OTStats/c381bb28947d5b75a326ab659f8a9dc0 to your computer and use it in GitHub Desktop.
install.packages("devtools")
devtools::install_github("mbjoseph/bbr")
library(bbr)
nba <- get_season(2025)
nba %>%
filter(team == "DEN") %>%
# arrange(desc(gs)) %>%
# group_by(team) %>%
mutate(total_games = sum(gs)/5) %>%
# group_by(player) %>%
mutate(min_perc = mp / (total_games *48)) %>%
# ungroup() %>%
ggplot(aes(x = age, y = min_perc)) +
geom_rect(
aes(xmin = 27, xmax = 31, ymin = 0, ymax = 1, alpha = .01),
fill = "steelblue",
inherit.aes = F
) +
geom_text_repel(aes(label = player)) +
scale_alpha_identity() +
geom_point() +
scale_y_continuous(limits = c(0, 1.02), expand = c(0.02, 0.02), breaks = seq(0,1,.2), labels = scales::percent_format()) +
scale_x_continuous(limits = c(18, 40), breaks = seq(18, 40, 4)) +
theme(
plot.background = element_blank(),
panel.background = element_blank(),
title = element_text(size = 14),
plot.subtitle = element_text(size = 10),
# axis.line.x.bottom = element_line(color = "lightgrey"),
panel.grid.major = element_line(color = "lightgrey"),
axis.ticks = element_blank()
) +
annotate(geom = "text",
x = 29, y = 1,
label = "Peak Years",
vjust = -0.3, alpha = 0.5, size = 3.4) +
labs(
title = "Denver Nuggest Roster Age Profile | NBA 2024-25",
subtitle = "Created by @OTStats",
# caption = "Data: Transfermarkt",
x = "Age",
y = "Share of Minutes Played"
)
@OTStats
Copy link
Author

OTStats commented Mar 1, 2025

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment