---
title: "From Survival to Stability"
subtitle: "Share of the global population across daily income thresholds (PPP-adjusted), 2000 vs. 2022"
description: "A proportional stacked bar chart tracking how the global population shifted across four daily income thresholds between 2000 and 2022. Extreme poverty (below $3/day) nearly halved from 36% to 11%, while the $10–$30/day bracket saw the largest expansion — from 13% to 27% — signaling the rise of a global middle. Built with ggplot2 using World Bank PIP data via Our World in Data."
date: "2026-04-09"
author:
- name: "Steven Ponce"
url: "https://stevenponce.netlify.app"
citation:
url: "https://stevenponce.netlify.app/data_visualizations/30DayChartChallenge/2026/30dcc_2026_09.html"
categories: ["30DayChartChallenge", "2026"]
tags: [
"30DayChartChallenge",
"Distributions",
"Wealth",
"Income Inequality",
"Global Poverty",
"Stacked Bar Chart",
"World Bank",
"Our World in Data",
"ggplot2",
"PPP",
"Economic Development",
"Middle Class"
]
image: "thumbnails/30dcc_2026_09.png"
format:
html:
toc: true
toc-depth: 5
code-link: true
code-fold: true
code-tools: true
code-summary: "Show code"
theme:
light: [flatly, assets/styling/custom_styles.scss]
dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options:
chunk_output_type: inline
execute:
freeze: true
cache: true
error: false
message: false
warning: false
eval: true
---
{#fig-1}
### [**Steps to Create this Graphic**]{.mark}
#### [1. Load Packages & Setup]{.smallcaps}
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"
## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
pacman::p_load(
tidyverse, ggtext, showtext, patchwork,
janitor, scales, glue
)
})
### |- figure size ----
camcorder::gg_record(
dir = here::here("temp_plots"),
device = "png",
width = 10,
height = 6,
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]{.smallcaps}
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
# Source: World Bank Poverty and Inequality Platform (2025) via Our World in Data
# Full dataset filtered to global aggregate (Entity == "World") for 2000 and 2022
# Raw columns are absolute population counts — converted to % shares in tidy step
income_raw <- read_csv(
here::here("data/30DayChartChallenge/2026/owid_income_distribution.csv"),
show_col_types = FALSE
) |>
clean_names() |>
filter(entity == "World", year %in% c(2000, 2022))
```
#### [3. Examine the Data]{.smallcaps}
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
glimpse(income_raw)
```
#### [4. Tidy Data]{.smallcaps}
```{r}
#| label: tidy
#| warning: false
# Bracket factor levels: low → high income
bracket_levels <- c(
"< $3",
"$3 – $10",
"$10 – $30",
"> $30"
)
income_df <- income_raw |>
# Convert absolute counts to % shares
mutate(
total = below_3_a_day + x3_10_a_day + x10_30_a_day + above_30_a_day,
"< $3" = below_3_a_day / total * 100,
"$3 – $10" = x3_10_a_day / total * 100,
"$10 – $30" = x10_30_a_day / total * 100,
"> $30" = above_30_a_day / total * 100
) |>
select(year, all_of(bracket_levels)) |>
pivot_longer(
cols = all_of(bracket_levels),
names_to = "bracket",
values_to = "share"
) |>
mutate(
bracket = factor(bracket, levels = bracket_levels),
year_lbl = factor(year, levels = c(2022, 2000), labels = c("2022", "2000"))
) |>
arrange(year, bracket) |>
group_by(year) |>
mutate(
xmax = cumsum(share),
xmin = xmax - share,
xmid = (xmin + xmax) / 2
) |>
ungroup()
### |- annotation anchors (data-driven) ----
ann_poverty_x <- income_df |>
filter(bracket == "< $3") |> summarise(xmid = mean(xmid)) |> pull(xmid)
ann_wealth_x <- income_df |>
filter(year == 2022, bracket == "> $30") |> pull(xmid)
ann_middle_x <- income_df |>
filter(year == 2022, bracket == "$10 – $30") |> pull(xmid)
### |- segment labels ----
income_labels <- income_df |>
filter(share >= 9)
```
#### [5. Visualization Parameters]{.smallcaps}
```{r}
#| label: params
#| include: true
#| warning: false
### |- plot aesthetics ----
colors <- get_theme_colors(
palette = c(
"< $3" = "#6B0F1A",
"$3 – $10" = "#C94A3A",
"$10 – $30" = "#8FAFC3",
"> $30" = "#1B3A52"
)
)
### |- titles and caption ----
title_text <- "From Survival to Stability"
subtitle_text <- "Share of the global population across daily income thresholds (PPP-adjusted), 2000 vs. 2022"
caption_text <- create_dcc_caption(
dcc_year = 2026,
dcc_day = 9,
source_text = "World Bank Poverty and Inequality Platform (2025) via Our World in Data"
)
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
font_body <- fonts$text %||% ""
font_title <- fonts$title %||% ""
font_caption <- fonts$caption %||% ""
### |- plot theme ----
base_theme <- create_base_theme(colors)
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
# Axes
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_text(
size = 14,
face = "plain",
family = fonts$text,
color = colors$text,
margin = margin(r = 8)
),
axis.ticks = element_blank(),
# Grid
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
# Legend
legend.position = "top",
legend.direction = "horizontal",
legend.title = element_blank(),
legend.text = element_text(
size = 9.5,
family = fonts$text,
color = colors$text
),
legend.key.width = unit(1.4, "cm"),
legend.key.height = unit(0.4, "cm"),
legend.spacing.x = unit(0.6, "cm"),
# Margins
plot.margin = margin(t = 10, r = 20, b = 10, l = 20)
)
)
theme_set(weekly_theme)
```
#### [6. Plot]{.smallcaps}
```{r}
#| label: plot
#| warning: false
### |- main plot ----
p <- ggplot(
data = income_df,
mapping = aes(x = share, y = year_lbl, fill = bracket)
) +
geom_col(
position = position_stack(reverse = TRUE),
width = 0.5,
color = "white",
linewidth = 0.3
) +
geom_text(
data = income_labels |> filter(bracket != "$10 – $30"),
mapping = aes(x = xmid, y = year_lbl, label = glue("{round(share)}%")),
color = "white",
size = 3.8,
fontface = "bold",
family = fonts$text,
inherit.aes = FALSE
) +
geom_text(
data = income_labels |> filter(bracket == "$10 – $30"),
mapping = aes(x = xmid, y = year_lbl, label = glue("{round(share)}%")),
color = "#0B1F2A",
size = 3.8,
fontface = "bold",
family = fonts$text,
inherit.aes = FALSE
) +
annotate(
"text",
x = ann_poverty_x, y = 2.45,
label = "Extreme poverty\nnearly halved",
size = 2.9,
color = colorspace::lighten(colors$text, 0.3),
family = fonts$text,
hjust = 0.5,
lineheight = 1.25
) +
annotate(
"text",
x = ann_wealth_x, y = 0.58,
label = "Above $30/day\nalmost doubled",
size = 2.9,
color = colorspace::lighten(colors$text, 0.3),
family = fonts$text,
hjust = 0.5,
lineheight = 1.25
) +
annotate(
"text",
x = ann_middle_x, y = 2.45,
label = "Largest growth:\n$10 – $30/day",
size = 3.6,
fontface = "bold",
color = colors$text,
family = fonts$text,
hjust = 0.5,
lineheight = 1.25
) +
scale_fill_manual(
values = unname(colors$palette),
breaks = bracket_levels,
guide = guide_legend(nrow = 1, reverse = FALSE)
) +
scale_x_continuous(
expand = expansion(mult = c(0, 0.01)),
limits = c(0, 100)
) +
labs(
title = title_text,
subtitle = subtitle_text,
caption = caption_text
) +
theme(
plot.title = element_text(
size = 22,
face = "bold",
family = fonts$title,
color = colors$title,
margin = margin(b = 6)
),
plot.subtitle = element_text(
size = 11,
family = fonts$text,
color = colors$text,
lineheight = 1.3,
margin = margin(b = 16)
),
plot.caption = element_markdown(
size = 7,
family = fonts$caption,
color = colors$caption,
hjust = 0,
lineheight = 1.2,
margin = margin(t = 14)
)
)
```
#### [7. Save]{.smallcaps}
```{r}
#| label: save
#| warning: false
### |- plot image ----
save_plot(
p,
type = "30daychartchallenge",
year = 2026,
day = 09,
width = 10,
height = 6
)
```
#### [8. Session Info]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for Session Info
```{r, echo = FALSE}
#| eval: true
#| warning: false
sessionInfo()
```
:::
#### [9. GitHub Repository]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo
The complete code for this analysis is available in [`30dcc_2026_09.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2026/30dcc_2026_09.qmd).
For the full repository, [click here](https://github.com/poncest/personal-website/).
:::
#### [10. References]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for References
1. Data Sources:
- World Bank Poverty and Inequality Platform. (2025). *Distribution of population
between different poverty lines* [Dataset]. Our World in Data.
Retrieved March 22, 2026 from
https://ourworldindata.org/grapher/distribution-of-population-between-different-poverty-thresholds-stacke-bar
:::
#### [11. Custom Functions Documentation]{.smallcaps}
::: {.callout-note collapse="true"}
##### 📦 Custom Helper Functions
This analysis uses custom functions from my personal module library for efficiency and consistency across projects.
**Functions Used:**
- **`fonts.R`**: `setup_fonts()`, `get_font_families()` - Font management with showtext
- **`social_icons.R`**: `create_social_caption()` - Generates formatted social media captions
- **`image_utils.R`**: `save_plot()` - Consistent plot saving with naming conventions
- **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()` - Custom ggplot2 themes
**Why custom functions?**\
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.
**Source Code:**\
View all custom functions → [GitHub: R/utils](https://github.com/poncest/personal-website/tree/master/R)
:::