Created
July 22, 2016 18:15
-
-
Save ckholmes5/a90f4c487ffbf66d2f2bfca6df6e1535 to your computer and use it in GitHub Desktop.
This file contains 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
map_df = map_df[order(map_df$order),] | |
years = sort(unique(statecrime$Year)) | |
maps = list() | |
for (i in 1:length(years)) { | |
df = subset(map_df, Year == years[i]) | |
g = ggplot(df, aes(x=long,y=lat,group=group))+ | |
geom_polygon(aes(fill=VC_rate))+ | |
geom_path()+ | |
coord_map()+ | |
scale_fill_gradient(limits = c(0,12), low='deepskyblue', high = 'red', breaks = c(0, 4,8, 12)) + | |
theme(axis.title = element_blank(), axis.text = element_blank(),panel.background = element_blank(), axis.ticks = element_blank(), legend.key.size = unit(.3, 'cm'), legend.title = element_text(size = 8))+ | |
labs(title = paste(years[i]), fill = 'Violent Crimes \n(per 1000 residents)') | |
ggsave(paste('~/', i, '.png'), device = 'png') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment