-
-
Save dgkeyes/259b33b3d24b1f4ac5e75865d5a8a82f to your computer and use it in GitHub Desktop.
This file contains 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
london_sf <- read_sf("data/london_boroughs") | |
education_data <- read_csv("data/age-when-completed-education.csv") | |
london_education_sf <- london_sf %>% | |
left_join(education_data, | |
by = c("lad11nm" = "area")) %>% | |
group_by(lad11nm) %>% | |
mutate(value = value / sum(value)) | |
# ==== data viz ==== | |
order_age_groups <- c("Still in education", | |
"16 or under", | |
"17-19", | |
"20-23", | |
"24+") | |
london_education_sf %>% | |
mutate(age_group = fct_relevel(age_group, order_age_groups)) %>% | |
ggplot() + | |
geom_sf(aes(fill = value, | |
shape = "City of London"), | |
color = "white", | |
size = 0.1) + | |
scale_fill_viridis_c(na.value = "pink", | |
labels = scales::percent_format(), | |
name = "% of population") + | |
facet_wrap(~age_group) + | |
guides(shape = guide_legend(override.aes = list(fill = "pink"), order = 2, title = NULL), | |
fill = guide_colorbar(order = 1, | |
barwidth = grid::unit(10, "cm"))) + | |
labs(title = "At what age do Londoners leave education?") + | |
theme_ipsum() + | |
theme(panel.grid.major = element_blank(), | |
axis.text.x = element_blank(), | |
axis.text.y = element_blank(), | |
legend.position = "top") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment