hafen / geofacet

R package for geographical faceting with ggplot2
https://hafen.github.io/geofacet/
Other
336 stars 45 forks source link

us_me_counties_grid #318

Closed dikbrown closed 1 week ago

dikbrown commented 3 years ago

This is a grid of the counties of the U.S. state of Maine. The attached plot shows the county-by-county split between Trump and Biden in the 2020 Presidential election.

Grid data:

row,col,code,name
1,3,ARO,Aroostook
3,4,PEN,Penobscot
3,3,PIS,Piscataquis
3,2,SOM,Somerset
4,1,FRA,Franklin
4,4,HAN,Hancock
4,2,KEN,Kennebec
4,3,WAL,Waldo
4,5,WAS,Washington
5,2,AND,Androscoggin
5,3,KNO,Knox
5,1,OXF,Oxford
6,1,CUM,Cumberland
6,3,LIN,Lincoln
6,2,SAG,Sagadahoc
7,1,YOR,York

map

Sample code: ggplot(data = election3, aes(x = Candidate, y = Votes/1000, fill = Candidate)) + geom_col() + coord_flip() + scale_fill_manual(values = c("Trump" = "red", "Biden" = "blue")) + facet_geo(~ Name, grid = us_me_counties_grid) + ggtitle("Results of 2020 Presidential Election by Maine County") + ylab("Thousands of Votes") + xlab("")

Dataset (modified from downloaded file at https://www.maine.gov/sos/cec/elec/results/2020/presandvisecnty1120.xlsx) :

"Name","Code","Candidate","Votes" "Androscoggin","AND","Biden",27617 "Androscoggin","AND","Trump",29268 "Aroostook","ARO","Biden",13956 "Aroostook","ARO","Trump",21080 "Cumberland","CUM","Biden",128759 "Cumberland","CUM","Trump",59584 "Franklin","FRA","Biden",8069 "Franklin","FRA","Trump",8754 "Hancock","HAN","Biden",19369 "Hancock","HAN","Trump",14982 "Kennebec","KEN","Biden",34902 "Kennebec","KEN","Trump",34721 "Knox","KNO","Biden",15110 "Knox","KNO","Trump",9982 "Lincoln","LIN","Biden",12684 "Lincoln","LIN","Trump",10256 "Oxford","OXF","Biden",14755 "Oxford","OXF","Trump",17698 "Penobscot","PEN","Biden",37713 "Penobscot","PEN","Trump",44825 "Piscataquis","PIS","Biden",3517 "Piscataquis","PIS","Trump",6143 "Sagadahoc","SAG","Biden",13528 "Sagadahoc","SAG","Trump",9755 "Somerset","SOM","Biden",10199 "Somerset","SOM","Trump",16644 "Waldo","WAL","Biden",12345 "Waldo","WAL","Trump",11196 "Washington","WAS","Biden",6761 "Washington","WAS","Trump",10194 "York","YOR","Biden",71189 "York","YOR","Trump",54817

dikbrown commented 3 years ago

By the way, this is what the plot looks like.

Me2020Election

hafen commented 1 week ago

Added in https://github.com/hafen/grid-designer/pull/8