grid <- tribble(
~st, ~col, ~row,
"ME",11,1, "WI",6,2, "VT",10,2, "NH",11,2, "WA",1,3, "ID",2,3, "MT",3,3, "ND",4,3, "MN",5,3, "IL",6,3, "MI",7,3, "NY",9,3, "MA",10,3, "RI",11,3,
"OR",1,4, "NV",2,4, "WY",3,4, "SD",4,4, "IA",5,4, "IN",6,4, "OH",7,4, "PA",8,4, "NJ",9,4, "CT",10,4,
"CA",1,5, "UT",2,5, "CO",3,5, "NE",4,5, "MO",5,5, "KY",6,5, "WV",7,5, "VA",8,5, "MD",9,5, "DE",10,5,
"AZ",2,6, "NM",3,6, "KS",4,6, "AR",5,6, "TN",6,6, "NC",7,6, "SC",8,6, "DC",9,6,
"OK",4,7, "LA",5,7, "MS",6,7, "AL",7,7, "GA",8,7, "TX",4,8, "FL",8,8)
abbr <- c(setNames(state.abb, state.name), "District of Columbia" = "DC")
st_cp <- acs |> mutate(st = abbr[state]) |> filter(!is.na(st), !is.na(child_poverty)) |>
group_by(st) |> summarise(cp = weighted.mean(child_poverty, pop), .groups = "drop") |>
right_join(grid, by = "st")
ggplot(st_cp, aes(col, -row, fill = cp)) +
geom_tile(color = mv_ink$canvas, linewidth = 1.5, width = 0.95, height = 0.95) +
geom_text(aes(label = st, color = cp > 24), size = 3, family = mv_font(), fontface = "bold") +
scale_color_manual(values = c(`TRUE` = mv_ink$canvas, `FALSE` = mv_ink$ink), guide = "none") +
scale_fill_gradientn(colors = mv_ramp_seq(9), name = "Child poverty rate (%)") +
coord_equal() +
labs(title = "Child poverty rate by state, 2011 to 2015",
subtitle = "Share of children below the poverty line,\ncounty data weighted by population",
caption = mv_source(src)) +
theme_map() + theme(legend.key.width = unit(2, "lines"))