Skip to content

Instantly share code, notes, and snippets.

@andrewbtran
Last active August 7, 2016 00:31
Show Gist options
  • Save andrewbtran/6b6244b571cd09130db73954763c8160 to your computer and use it in GitHub Desktop.
Save andrewbtran/6b6244b571cd09130db73954763c8160 to your computer and use it in GitHub Desktop.
Making a choropleth of stops in Hamden
# Join the by_tract points to polygon dataframe to the original census tracts dataframe
total_map <- left_join(towntracts, by_tract)
require(ggmap)
require(scales)
tm_ct <- ggplot() +
geom_polygon(data = total_map, aes(x=long, y=lat, group=group, fill=total), color = "black", size=0.2) +
geom_polygon(data = total_map, aes(x=long, y=lat, group=group, fill=total), color = "black", size=0.2) +
coord_map() +
scale_fill_distiller(type="seq", trans="reverse", palette = "Reds", breaks=pretty_breaks(n=10)) +
theme_nothing(legend=TRUE) +
labs(title="Where Hamden police conduct traffic stops", fill="")
print(tm_ct)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment