我正在使用以下国会选区地图:
get_congress_map <- function(cong=113) {
tmp_file <- tempfile()
tmp_dir <- tempdir()
zp <- sprintf("http://cdmaps.polisci.ucla.edu/shp/districts%03i.zip",cong)
download.file(zp, tmp_file)
unzip(zipfile = tmp_file, exdir = tmp_dir)
fpath <- paste(tmp_dir, sprintf("districtShapes/districts%03i.shp",cong), sep = "/")
st_read(fpath)
}
cd114 <- get_congress_map(114)
ggplot() +
geom_sf(data=cd114.1,aes(geometry = geometry,),inherit.aes=FALSE,alpha=0.9) +
scale_fill_gradient(low = "white", high = "black", limits=c(20,80)) +
theme_void() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())
看起来是这样的:
非常感谢你的帮助。