Created
November 11, 2022 15:50
-
-
Save walkerke/eb80178f7071da04589c68e15c4e8c91 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() | |
red_counties <- counties(cb = TRUE, resolution = "20m") %>% | |
filter(str_detect(NAME, "Red|Rojo|Roja|Rouge")) %>% | |
shift_geometry() | |
red_places <- places(cb = TRUE) %>% | |
filter(str_detect(NAME, "Red|Rojo|Roja|Rouge"), | |
STATEFP != "78") %>% | |
st_centroid() %>% | |
shift_geometry() | |
ggplot() + | |
with_shadow( | |
geom_sf(data = state_borders, fill = "grey80", color = "grey20"), | |
colour = "red", x_offset = -3, y_offset = 3 | |
) + | |
with_shadow( | |
geom_sf(data = red_counties, fill = "red", color = "white"), | |
colour = "white", x_offset = -1, y_offset = 1 | |
) + | |
geom_sf(data = red_places, color = "white", alpha = 0.75, | |
fill = "red", shape = 21) + | |
theme_void(base_size = 16, base_family = "Roboto") + | |
labs(title = "Seeing Red(lands)", | |
subtitle = "U.S. counties & cities with 'Red', 'Rojo/a', or 'Rouge' in their names", | |
caption = "@kyle_e_walker | tigris R package") + | |
theme(plot.margin = margin(0, 0.1, 0, 0, "cm")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment