Skip to content

Instantly share code, notes, and snippets.

@kjhealy
Last active September 25, 2021 03:29
Show Gist options
  • Save kjhealy/cdc8cfab78184bec06fba94c5b9fe6e9 to your computer and use it in GitHub Desktop.
Save kjhealy/cdc8cfab78184bec06fba94c5b9fe6e9 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(cowplot)
df <- read_csv("https://osf.io/qmhgw/download")
out <- df %>%
ggplot(mapping = aes(x = year,
y = oneper,
group = country,
color = Region)) +
geom_point() +
geom_line() +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
facet_wrap(~ reorder(Region, -oneper, mean, na.rm = TRUE),
labeller = label_wrap_gen(20),
nrow = 1) +
labs(x = "Year", y = "Percent",
title = "One-person households as a percentage of all households",
caption = "PN Cohen analysis of international census data via IPUMS"
) +
guides(color = "none") +
theme_minimal_grid(font_size = 12) +
theme(panel.spacing = unit(1.5, "lines"),
plot.margin = margin(0.5, 0.75, 0.5, 0.5, "cm"))
ggsave("pnc.pdf", out, width = 11, height = 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment