Created
November 10, 2022 14:48
-
-
Save walkerke/a5006f8129f8f76a3442b518d2fab3ea 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(tigris) | |
library(tidyverse) | |
library(showtext) | |
library(sf) | |
library(ggfx) | |
options(tigris_use_cache = TRUE) | |
font_add_google("Roboto", "Roboto") | |
showtext_auto() | |
state_borders <- states(cb = TRUE, resolution = "20m") %>% | |
shift_geometry(position = "outside") | |
bad_counties <- counties(cb = TRUE, resolution = "20m") %>% | |
filter(str_detect(NAME, "Bad|Mal")) %>% | |
shift_geometry(position = "outside") | |
bad_places <- places(cb = TRUE) %>% | |
filter(str_detect(NAME, "Bad|Mal"), STATEFP < "60") %>% | |
st_centroid() %>% | |
shift_geometry(position = "outside") | |
ggplot() + | |
with_shadow( | |
geom_sf(data = state_borders, fill = "grey80", color = "grey20"), | |
colour = "grey10", x_offset = -3, y_offset = 3 | |
) + | |
with_shadow( | |
geom_sf(data = bad_counties, fill = "grey10", color = "white"), | |
colour = "white", x_offset = -1, y_offset = 1 | |
) + | |
geom_sf(data = bad_places, color = "white", alpha = 0.75, | |
fill = "grey10", shape = 21, size = 2) + | |
theme_void(base_size = 16, base_family = "Roboto") + | |
labs(title = "Bad Places", | |
subtitle = "U.S. counties & cities with 'Bad' or 'Mal' in their name", | |
caption = "@kyle_e_walker | tigris R package") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment