---
title: "Health financing moved in three directions"
subtitle: "Each arrow shows how a country's mix of health funding changed from 2000 to 2023. Moving toward a corner means a larger share from that source. Countries are grouped by the source whose share grew most (darker arrows: that share rose 5 points or more). Private funding lost share in 111 of 148 countries."
description: "Between 2000 and 2023, government's share of health funding grew most in 74 of 148 countries, foreign funding's in 45 and private funding's in 29. Ternary arrows trace each country's mix of government, private and foreign sources, computed from WHO spending in constant US dollars. Built in R with ggplot2, ggtext and showtext."
date: "2026-12-01"
author:
- name: "Steven Ponce"
url: "https://stevenponce.netlify.app"
citation:
url: "https://stevenponce.netlify.app/data_visualizations/SWD%20Challenge/2026/swd_2026_12.html"
categories: ["SWDchallenge", "2026"]
tags: [
"SWDchallenge",
"borrow-a-chart",
"ternary-plot",
"small-multiples",
"arrow-chart",
"compositional-data",
"health-financing",
"global-health",
"who-ghed",
"annotation",
"ggtext",
"tidytuesday-data",
"2026"
]
image: "thumbnails/swd_2026_12.png"
format:
html:
toc: true
toc-depth: 4
code-link: true
code-fold: true
code-tools: true
code-summary: "Show code"
editor_options:
chunk_output_type: inline
execute:
freeze: true
cache: false
error: false
message: false
warning: false
eval: true
---
### Challenge
Most of the charts we make for work are familiar ones: bar charts, line graphs, and tables. But some industries turn to more specialized charts that are commonplace to them and rarely seen elsewhere. This month's challenge is to borrow one and use it to share a story with data.
Additional information can be found [HERE](https://community.storytellingwithdata.com/challenges/dec-2026-borrow-a-chart-from-another-industry)
### Visualization
{#fig-1}
::: {.key-takeaways}
[Key takeaways]{.key-takeaways-label}
- Countries did not all move toward the same health financing model. Where private funding lost share substantially, government funding was more often the largest gainer than foreign funding.
- Of the 95 countries where private funding's share fell by more than 2 percentage points, government funding gained more share in 62 and foreign funding in 33.
- Across the 175 countries with 2023 data, foreign funding made up 11.0% of the average country's health financing mix but just 0.3% of their combined health spending. The chart gives each country equal weight, regardless of how much it spends on health.
:::
### [**Steps to Create this Graphic**]{.mark}
#### [1. Load Packages & Setup]{.smallcaps}
```{r}
#| label: load
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
tidyverse, ggtext, showtext, janitor, scales, glue, ggview
)
# 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"))
### |- figure settings ----
fig_w <- 13
fig_h <- 6
fig_dpi <- 320
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
title_family <- fonts$title_1
title_size <- 30
```
#### [2. Read in the Data]{.smallcaps}
```{r}
#| label: read
## Every field as character, no NA tokens (a literal "NA" can be a real code).
tt_url <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-04-21/"
health_raw <- read_csv(paste0(tt_url, "health_spending.csv"),
col_types = cols(.default = col_character()), na = character(), show_col_types = FALSE
)
```
#### [3. Examine the Data]{.smallcaps}
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
glimpse(health_raw)
health_raw |> count(indicator_code)
```
#### [4. Tidy Data]{.smallcaps}
```{r}
#| label: tidy
#| output: false
### |- shares from constant-2023 US$, 2000 and 2023 ----
shares <- health_raw |>
filter(
indicator_code %in% c("gghed_usd2023", "pvtd_usd2023", "ext_usd2023"),
year %in% c("2000", "2023"), value != "NA"
) |>
mutate(value = as.numeric(value)) |>
select(iso3_code, country_name, year, indicator_code, value) |>
pivot_wider(names_from = indicator_code, values_from = value) |>
drop_na() |>
mutate(
total = gghed_usd2023 + pvtd_usd2023 + ext_usd2023,
gov = gghed_usd2023 / total, pvt = pvtd_usd2023 / total, ext = ext_usd2023 / total
) |>
filter(total > 0) |>
select(iso3_code, country_name, year, gov, pvt, ext)
### |- one row per country: 2000 -> 2023 ----
moves <- shares |>
pivot_wider(names_from = year, values_from = c(gov, pvt, ext)) |>
drop_na() |>
mutate(
d_gov = gov_2023 - gov_2000, d_pvt = pvt_2023 - pvt_2000, d_ext = ext_2023 - ext_2000,
gain_max = pmax(d_gov, d_pvt, d_ext),
grew = case_when(
d_gov == gain_max ~ "gov",
d_ext == gain_max ~ "ext",
TRUE ~ "pvt"
),
clear = gain_max >= 0.05,
# ternary -> plane: government (0, 0), private (1, 0), foreign (0.5, sqrt(3)/2)
x0 = pvt_2000 + ext_2000 / 2, y0 = ext_2000 * sqrt(3) / 2,
x1 = pvt_2023 + ext_2023 / 2, y1 = ext_2023 * sqrt(3) / 2
)
### |- numbers for the copy (all from the data) ----
n_countries <- nrow(moves)
n_grew <- count(moves, grew) |> deframe()
n_clear <- sum(moves$clear)
n_small <- n_countries - n_clear
n_pvt_fell <- sum(moves$d_pvt < 0)
### |- panel headings ----
panel_lab <- c(
gov = glue("Government's share grew most<br><span style='font-size:11pt'>{n_grew['gov']} countries</span>"),
ext = glue("Foreign funding's share grew most<br><span style='font-size:11pt'>{n_grew['ext']} countries</span>"),
pvt = glue("Private share grew most<br><span style='font-size:11pt'>{n_grew['pvt']} countries</span>")
)
moves <- moves |> mutate(panel = factor(panel_lab[grew], levels = panel_lab))
### |- worked example: one real arrow, chosen by a rule declared before rendering ----
## Rule (2026-12-01): government panel; clear movers (government share +5 pts or more) whose
## foreign share is >= 5% at both ends (off the bottom edge); pick the arrow whose length is
## nearest the median length of ALL arrows in the government panel.
gov_panel <- moves |> filter(grew == "gov") |> mutate(len = sqrt((x1 - x0)^2 + (y1 - y0)^2))
example <- gov_panel |>
filter(d_gov >= 0.05, ext_2000 >= 0.05, ext_2023 >= 0.05) |>
slice_min(abs(len - median(gov_panel$len)), n = 1, with_ties = FALSE)
## label block in the empty upper-left of the panel, one leader to the arrow's midpoint;
## short year tags at tail (2000) and head (2023)
example_note <- tibble(
panel = factor(panel_lab["gov"], levels = panel_lab),
x = 0.215, y = 0.60, # outside the left edge: no arrow passes here
label = glue("{example$country_name}\ndot = 2000\narrowhead = 2023\ngovernment\n{percent(example$gov_2000, 1)} \u2192 {percent(example$gov_2023, 1)}"),
lead_x = 0.20, lead_y = 0.37,
mid_x = (example$x0 + example$x1) / 2, mid_y = (example$y0 + example$y1) / 2
)
example_tags <- tibble(
panel = factor(panel_lab["gov"], levels = panel_lab),
x = c(example$x0 + 0.015, example$x1 - 0.012),
y = c(example$y0 + 0.012, example$y1 + 0.03),
hjust = c(0, 1), label = c("2000", "2023")
)
edge_label <- tibble(
panel = factor(panel_lab["gov"], levels = panel_lab),
x = 0.5, y = -0.075, label = "Bottom edge: 0% foreign funding"
)
### |- triangle scaffold (repeats in every panel) ----
h <- sqrt(3) / 2
tri <- tibble(x = c(0, 1, 0.5, 0), y = c(0, 0, h, 0))
grid_lines <- map_dfr(c(0.25, 0.5, 0.75), \(s) bind_rows(
tibble(set = "ext", x = c(s / 2, 1 - s / 2), y = s * h), # foreign share = s
tibble(set = "pvt", x = c(s, 0.5 + s / 2), y = c(0, (1 - s) * h)), # private share = s
tibble(set = "gov", x = c(1 - s, 0.5 - s / 2), y = c(0, (1 - s) * h)) # government share = s
) |> mutate(level = s))
corners <- tibble( # centred under / over each vertex: no clash with the next panel
x = c(0, 1, 0.5), y = c(-0.075, -0.075, h + 0.05),
label = c("Government", "Private", "Foreign"), hjust = 0.5
)
```
#### [5. Visualization Parameters]{.smallcaps}
```{r}
#| label: params
### |- plot aesthetics ----
clrs <- get_theme_colors(
palette = list(
accent = "#722F37",
muted = "#B9B1A7",
frame = "#8C847C",
grid = "#E4DFD6"
)
)
col_ink <- clrs$title
col_label <- clrs$label
col_second <- clrs$caption
col_accent <- clrs$palette$accent
col_muted <- clrs$palette$muted
col_frame <- clrs$palette$frame
col_grid <- clrs$palette$grid
### |- titles and caption ----
title_text <- "Health financing moved in three directions"
subtitle_text <- glue(
"Each arrow shows how a country's mix of health funding changed from 2000 to 2023. ",
"Moving toward a corner means a larger share from that source. ",
"Countries are grouped by the source whose share grew most ",
"(<span style='color:{col_accent}'>**darker arrows**</span>: that share rose 5 points or more). ",
"Private funding lost share in {n_pvt_fell} of {n_countries} countries."
)
caption_note <- glue(
"Shares of current health expenditure, not amounts. {n_countries} countries with data for 2000 and 2023. ",
"Private: households, employers and non-profits, including out-of-pocket payments. ",
"Foreign: all funding from outside the country. Arrows are straight lines between 2000 and 2023; the years between are not drawn."
)
caption_text <- paste0(
caption_note, "<br>",
create_swd_caption(
year = 2026,
month = "Dec",
source_text = "WHO Global Health Expenditure Database via TidyTuesday"
)
)
### |- plot theme ----
base_theme <- create_base_theme(clrs)
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
plot.title = element_text(
face = "bold", family = title_family, size = title_size,
color = col_ink, margin = margin(b = 8)
),
plot.subtitle = element_textbox_simple(
family = fonts$subtitle, size = 11.5, color = col_second,
lineheight = 1.3, margin = margin(b = 18)
),
plot.caption = element_textbox_simple(
family = fonts$caption, size = 7, color = col_second,
lineheight = 1.35, margin = margin(t = 14)
),
strip.text = element_textbox_simple(
family = fonts$text, face = "bold", size = 13, color = col_ink,
halign = 0.5, lineheight = 1.2, margin = margin(b = 14)
),
axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.spacing = unit(5, "lines"),
plot.margin = margin(16, 30, 10, 30)
)
)
theme_set(weekly_theme)
```
#### [6. Plot]{.smallcaps}
```{r}
#| label: plot
#| output: false
### |- main plot ----
arrow_head <- arrow(length = unit(0.055, "in"), type = "closed")
p <- ggplot() +
# Geoms
geom_line(data = grid_lines, aes(x, y, group = interaction(set, level)), color = col_grid, linewidth = 0.3) +
geom_path(data = tri, aes(x, y), color = col_frame, linewidth = 0.45) +
geom_segment(
data = filter(moves, !clear), aes(x0, y0, xend = x1, yend = y1),
color = col_muted, linewidth = 0.3, arrow = arrow_head
) +
geom_segment(
data = filter(moves, clear), aes(x0, y0, xend = x1, yend = y1),
color = col_accent, linewidth = 0.4, arrow = arrow_head
) +
geom_segment( # casing: background-coloured underlay isolates the example arrow
data = mutate(example, panel = factor(panel_lab["gov"], levels = panel_lab)),
aes(x0, y0, xend = x1, yend = y1), color = clrs$background, linewidth = 2.4,
arrow = arrow(length = unit(0.09, "in"), type = "closed")
) +
geom_segment(
data = mutate(example, panel = factor(panel_lab["gov"], levels = panel_lab)),
aes(x0, y0, xend = x1, yend = y1), color = col_ink, linewidth = 0.7, arrow = arrow_head
) +
# Annotate
geom_segment(
data = example_note, aes(lead_x, lead_y, xend = mid_x, yend = mid_y),
color = col_ink, linewidth = 0.3
) +
geom_text(
data = example_note, aes(x, y, label = label),
family = fonts$text, size = 3.1, color = col_ink, lineheight = 0.95, hjust = 1, vjust = 1
) +
geom_point( # the example's 2000 position (the only start dot on the chart)
data = mutate(example, panel = factor(panel_lab["gov"], levels = panel_lab)),
aes(x0, y0), color = col_ink, fill = clrs$background, shape = 21, size = 2.2, stroke = 0.7
) +
geom_text(
data = edge_label, aes(x, y, label = label),
family = fonts$text, size = 3.1, color = col_label, fontface = "italic"
) +
geom_text(
data = corners, aes(x, y, label = label, hjust = hjust),
family = fonts$text, size = 3.6, color = col_label
) +
# Scales
coord_equal(xlim = c(-0.02, 1.02), ylim = c(-0.02, h + 0.02), clip = "off") +
facet_wrap(~panel, nrow = 1) +
# Labs
labs(title = title_text, subtitle = subtitle_text, caption = caption_text)
```
#### [7. Save]{.smallcaps}
```{r}
#| label: save
#| warning: false
### |- save ----
main_path <- here::here("data_visualizations", "SWD Challenge", "2026", "swd_2026_12.png")
thumb_path <- here::here("data_visualizations", "SWD Challenge", "2026", "thumbnails", "swd_2026_12.png")
# Full-size version, for the QMD figure
save_ggplot(
plot = p,
file = main_path,
width = fig_w,
height = fig_h,
units = "in",
dpi = fig_dpi,
create.dir = TRUE
)
# Reduced-size thumbnail, for the YAML `image:` field
fs::dir_create(dirname(thumb_path))
magick::image_read(main_path) |>
magick::image_resize("400") |>
magick::image_write(thumb_path)
```
#### [8. Reproduce]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Session info
```{r}
#| eval: true
#| warning: false
sessionInfo()
```
:::
::: {.callout-tip collapse="true"}
##### Code
The complete code for this analysis is in [`swd_2026_12.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/SWD%20Challenge/2026/swd_2026_12.qmd). The full site is in the [poncest/personal-website repository](https://github.com/poncest/personal-website/).
:::
::: {.callout-tip collapse="true"}
##### References
**Primary data**
- World Health Organization. *Global Health Expenditure Database (GHED)*. [apps.who.int/nha/database](https://apps.who.int/nha/database/)
**Source used here**
- TidyTuesday 2026, week 16 (2026-04-21): `health_spending.csv`, curated by Luca Picci (ONE Data) with the `bblocks-data-importers` package. [rfordatascience/tidytuesday](https://github.com/rfordatascience/tidytuesday/tree/main/data/2026/2026-04-21)
**Definitions (WHO)**
- Government: domestic government revenues and social health insurance contributions. [GGHE-D](https://www.who.int/data/gho/data/indicators/indicator-details/GHO/domestic-general-government-health-expenditure-(gche-d)-as-percentage-of-current-health-expenditure)
- Private: households, corporations and non-profits, prepaid or out-of-pocket. [PVT-D](https://www.who.int/data/gho/data/indicators/indicator-details/GHO/domestic-private-health-expenditure-(pvt-d)-as-percentage-of-current-health-expenditure-(che)-(-))
- Foreign: all funding from outside the country, including foreign transfers distributed by government. [EXT](https://www.who.int/data/gho/data/indicators/indicator-details/GHO/external-health-expenditure-(ext)-as-percentage-of-current-health-expenditure-(che)-(-))
**Analysis**
- 148 countries with all three sources in both 2000 and 2023. Shares are computed from constant 2023 US$ amounts, where the three sources sum to current health expenditure; WHO's published percentage fields are rounded and not used.
- Each country sits in the panel of the source whose share grew most. Darker arrows mark a largest gain of 5 percentage points or more: a design threshold for emphasis, not a significance test.
- Suriname was chosen as the worked example by a rule fixed before rendering: the government-panel arrow nearest the panel's median length, among countries off the bottom edge.
- Every number in the chart and the takeaways is reproduced by the [decision record](https://github.com/poncest/SWDchallenge/blob/main/2026/12_Dec/decisions/swd_2026_12_decision_record.R).
**Claim limits**
- Shares, not amounts: a rising foreign share can mean more foreign money or less domestic money.
- Each arrow joins two endpoints; the path between 2000 and 2023 is not shown.
- Countries count equally: across the 175 countries with 2023 data, foreign funding was 11.0% of the average country's mix but 0.3% of combined spending.
- The data describe composition, not causes, and end in 2023.
**Challenge**
- Storytelling with Data. *DEC 2026: borrow a chart from another industry*. [community.storytellingwithdata.com](https://community.storytellingwithdata.com/challenges/dec-2026-borrow-a-chart-from-another-industry)
:::
::: {.callout-note collapse="true"}
##### Helper functions
This analysis uses functions from my personal module library. The data tidying and chart logic use standard tidyverse packages.
**Functions used:**
- **`fonts.R`**: `setup_fonts()`, `get_font_families()`: font management with showtext
- **`social_icons.R`**: `create_swd_caption()`: formatted SWD challenge caption with social handles
- **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()`: custom ggplot2 themes
[Browse the helper functions on GitHub](https://github.com/poncest/personal-website/tree/master/R)
:::