-
-
Save pecard/271376 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
#! Mapa distribuição de variáveis sobre maps do pack map - GGPLOT | |
library(ggplot2) | |
#extract reference data | |
mapcounties <- map_data("county") | |
mapstates <- map_data("state") | |
#merge data with ggplot county coordinates | |
mapcounties$county <- with(mapcounties , paste(region, subregion, sep = ",")) | |
mergedata <- merge(mapcounties, unemp_data, by.x = "county", by.y = "counties") | |
mergedata <- mergedata[order(mergedata$order),] | |
#draw map | |
map <- ggplot(mergedata, aes(long,lat,group=group)) + geom_polygon(aes(fill=colorBuckets)) | |
map <- map + scale_fill_brewer(palette="PuRd") + coord_map(project="globular") + opts(legend.position = "none") | |
#add state borders | |
map <- map + geom_path(data = mapstates, colour = "white", size = .75) | |
#add county borders | |
map <- map + geom_path(data = mapcounties, colour = "white", size = .5, alpha = .1) | |
map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment