tibble(
sex = rep(c("Men", "Women"), each = 6),
children = rep(c("Parents", "Non-Parents"), times = 6),
education = rep(c("College Degree", "No College", "Some College"), 2, NA, 2),
percent = c(36, 35, 40, 38, 24, 27, 31, 47, 41, 27, 28, 26),
label = str_c(c(36, 35, 39, 38, 24, 27, 31, 47, 41, 27, 28, 26), "%"),
fontface = c(rep("plain", 6), rep("bold", 2), rep("plain", 4))) |>
mutate(
education = fct_relevel(education, "No College", "Some College"),
children = fct_relevel(children, "Parents")) |>
ggplot() +
aes(
x = children,
fill = education,
y = percent,
label = label,
fontface = fontface) +
geom_col(position = position_stack(), colour = "white") +
geom_text(
aes(group = interaction(sex, education)),
size = 6,
colour = "white",
position = position_stack(vjust = 0.5)) +
scale_x_discrete(position = "top") +
scale_fill_manual(
values = c(
"No College" = "grey80",
"Some College" = "grey69", # saturation midpoint
"College Degree" = "cornflowerblue")) +
facet_grid(cols = vars(sex)) +
labs(
title = "Education negatively correlated with motherhood, but not fatherhood",
subtitle = "College degree attainment of Americans 50+, grouped by sex and parenthood",
caption = "Source: Pew Research Center, \"The Experiences of U.S. Adults Who Don't Have Children,\" 2021-22") +
theme_minimal(base_size = 14) +
theme(
axis.title = element_blank(),
axis.text = element_text(size = 14),
axis.text.y = element_blank(),
legend.title = element_blank(),
legend.position = "top",
panel.grid = element_blank(),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(face = "italic", colour = "grey20"),
strip.placement = "outside",
strip.text = element_text(size = 18, face = "bold"))