---
title: "Distribution of Offensive Rebounding Specialization by Position (2024 NBA Season)"
subtitle: "Offensive rebounds as a proportion of total rebounds - Notice the multi-modal patterns"
description: "An analysis of NBA player rebounding specialization patterns using ridge plots to visualize multi-modal distributions. This visualization for Day 10 of the #30DayChartChallenge explores how players within the same position show different rebounding tendencies, with particular focus on offensive rebounding ratios."
author: "Steven Ponce"
date: "2025-04-10"
categories: ["30DayChartChallenge", "2025"]
tags: [
"ggplot2", "ggridges", "basketball", "hoopR", "NBA", "sports analytics", "multi-modal", "distribution", "ridge plot", "offensive rebounding", "player specialization"
]
image: "thumbnails/30dcc_2025_10.png"
format:
html:
toc: true
toc-depth: 5
code-link: true
code-fold: true
code-tools: true
code-summary: "Show code"
editor_options:
chunk_output_type: inline
execute:
freeze: true
cache: true
error: false
message: false
warning: false
eval: true
# filters:
# - social-share
# share:
# permalink: "https://stevenponce.netlify.app/data_visualizations/30DayChartChallenge/2025/30dcc_2025_10.html"
# description: "Exploring multi-modal distributions in NBA player rebounding patterns. See how positions like centers and forwards show distinct specialization types in their offensive rebounding approach. #30DayChartChallenge #DataViz #NBA"
# twitter: true
# linkedin: true
# email: true
# facebook: false
# reddit: false
# stumble: false
# tumblr: false
# mastodon: true
# bsky: true
---
{#fig-1}
### <mark> **Steps to Create this Graphic** </mark>
#### 1. Load Packages & Setup
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"
## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
pacman::p_load(
tidyverse, # Easily Install and Load the 'Tidyverse'
tidyverse, # Easily Install and Load the 'Tidyverse'
ggtext, # Improved Text Rendering Support for 'ggplot2'
showtext, # Using Fonts More Easily in R Graphs
janitor, # Simple Tools for Examining and Cleaning Dirty Data
skimr, # Compact and Flexible Summaries of Data
scales, # Scale Functions for Visualization
lubridate, # Make Dealing with Dates a Little Easier
hoopR, # Access Men's Basketball Play by Play Data
ggridges, # Ridgeline Plots in 'ggplot2'
camcorder # Record Your Plot History
)
})
### |- figure size ----
gg_record(
dir = here::here("temp_plots"),
device = "png",
width = 10,
height = 8,
units = "in",
dpi = 320
)
# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```
#### 2. Read in the Data
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
# Get NBA player stats for 2024 season
nba_players_2024 <- load_nba_player_box(seasons = 2024)
```
#### 3. Examine the Data
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
glimpse(nba_players_2024)
skim(nba_players_2024)
```
#### 4. Tidy Data
```{r}
#| label: tidy
#| warning: false
### |- Tidy ----
# Season stats
player_season_stats <- nba_players_2024 |>
group_by(athlete_id, athlete_display_name, athlete_position_abbreviation) |>
summarize(
games_played = n(),
across(
c(minutes, points, field_goals_attempted, field_goals_made,
three_point_field_goals_attempted, three_point_field_goals_made,
free_throws_attempted, free_throws_made, offensive_rebounds,
defensive_rebounds, rebounds, assists, turnovers, steals, blocks),
~ sum(.x, na.rm = TRUE),
.names = "total_{.col}"
),
.groups = "drop"
)
# Players stats
players_stats <- player_season_stats |>
filter(total_minutes > 0, games_played >= 10) |>
mutate(
# metrics
min_per_game = total_minutes / games_played,
three_pt_rate = total_three_point_field_goals_attempted / total_minutes,
# Free throw rate (FT attempts per minute)
ft_rate = total_free_throws_attempted / total_minutes,
# Offensive rebounding ratio (percentage of total rebounds that are offensive)
orb_ratio = total_offensive_rebounds / (total_offensive_rebounds + total_defensive_rebounds + 0.001),
# Shooting distance preference (proxy using 3PT to total FG ratio)
three_pt_preference = total_three_point_field_goals_attempted / (total_field_goals_attempted + 0.001)
) |>
filter(min_per_game >= 10)
```
#### 5. Visualization Parameters
```{r}
#| label: params
#| include: true
#| warning: false
### |- plot aesthetics ----
colors <- get_theme_colors(
palette = c("#3182bd", "Positive Impact" = "#333333")
)
### |- titles and caption ----
# text
title_text <- str_wrap("Distribution of Offensive Rebounding Specialization by Position (2024 NBA Season)",
width = 60)
subtitle_text <- str_wrap("Offensive rebounds as a proportion of total rebounds - Notice the multi-modal patterns",
width = 100)
# Create caption
caption_text <- create_dcc_caption(
dcc_year = 2025,
dcc_day = 10,
source_text = "ESPN via { hoopR } package"
)
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
### |- plot theme ----
# Start with base theme
base_theme <- create_base_theme(colors)
# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
# Text styling
plot.title = element_text(face = "bold", family = fonts$title, size = rel(1.14), margin = margin(b = 10)),
plot.subtitle = element_text(family = fonts$subtitle, color = colors$text, size = rel(0.78), margin = margin(b = 20)),
# Axis elements
axis.title = element_text(color = colors$text, size = rel(0.8)),
axis.text = element_text(color = colors$text, size = rel(0.7)),
axis.text.y = element_text(color = colors$text, size = rel(0.68)),
axis.line.x = element_line(color = "gray50", linewidth = .2),
# Grid elements
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
# Legend elements
legend.position = "top",
legend.title = element_text(family = fonts$text, size = rel(0.8)),
legend.text = element_text(family = fonts$text, size = rel(0.7)),
# Plot margins
plot.margin = margin(t = 10, r = 20, b = 10, l = 20),
)
)
# Set theme
theme_set(weekly_theme)
```
#### 6. Plot
```{r}
#| label: plot
#| warning: false
### |- Plot ----
p <- ggplot(players_stats, aes(x = orb_ratio, y = athlete_position_abbreviation)) +
# Geoms
geom_density_ridges(alpha = 0.7, scale = 1.2, rel_min_height = 0.01, fill = colors$palette[1]) +
# Annotation
annotate("text", x = 0.25, y = 4.4, label = "Defensive-focused PFs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("text", x = 0.35, y = 4.4, label = "Balanced PFs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("segment", x = 0.25, xend = 0.25, y = 4.2, yend = 4, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
annotate("segment", x = 0.35, xend = 0.35, y = 4.2, yend = 4, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
annotate("text", x = 0.20, y = 2.4, label = "Perimeter Fs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("text", x = 0.40, y = 2.4, label = "Inside Fs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("segment", x = 0.20, xend = 0.20, y = 2.2, yend = 2, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
annotate("segment", x = 0.40, xend = 0.40, y = 2.2, yend = 2, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
annotate("text", x = 0.35, y = 1.4, label = "Traditional Cs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("text", x = 0.48, y = 1.4, label = "Offensive-focused Cs", size = 3.5, fontface = "italic", color = colors$palette[2]) +
annotate("segment", x = 0.35, xend = 0.35, y = 1.2, yend = 1, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
annotate("segment", x = 0.48, xend = 0.47, y = 1.2, yend = 1, arrow = arrow(length = unit(0.2, "cm")), color = colors$palette[2]) +
# Scales
scale_x_continuous(
limits = c(0, 0.6),
breaks = seq(0, 0.6, by = 0.1)
) +
# Labs
labs(
title = title_text,
subtitle = subtitle_text,
caption = caption_text,
x = "Offensive Rebounding Ratio",
y = "Position"
) +
# Theme
theme(
plot.title = element_text(
size = rel(1.9),
family = fonts$title,
face = "bold",
color = colors$title,
margin = margin(t = 5, b = 5)
),
plot.subtitle = element_text(
size = rel(1),
family = fonts$subtitle,
color = colors$subtitle,
lineheight = 1.2,
margin = margin(t = 5, b = 20)
),
plot.caption = element_markdown(
size = rel(0.6),
family = fonts$caption,
color = colors$caption,
lineheight = 0.65,
hjust = 0.5,
halign = 0.5,
margin = margin(t = 10, b = 5)
),
)
```
#### 7. Save
```{r}
#| label: save
#| warning: false
### |- plot image ----
save_plot(
p,
type = "30daychartchallenge",
year = 2025,
day = 10,
width = 10,
height = 8
)
```
#### 8. Session Info
::: {.callout-tip collapse="true"}
##### Expand for Session Info
```{r, echo = FALSE}
#| eval: true
#| warning: false
sessionInfo()
```
:::
#### 9. GitHub Repository
::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo
The complete code for this analysis is available in [`30dcc_2025_10.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2025/30dcc_2025_10.qmd).
For the full repository, [click here](https://github.com/poncest/personal-website/).
:::
#### 10. References
::: {.callout-tip collapse="true"}
##### Expand for References
1. Data Sources:
- ESPN via { hoopR } package: [hoopR](https://github.com/sportsdataverse/hoopR)
:::