Last active
September 25, 2021 03:29
-
-
Save kjhealy/cdc8cfab78184bec06fba94c5b9fe6e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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