Created
February 24, 2017 19:52
-
-
Save sharan-naribole/bb4b7110431679b60c80584341390d22 to your computer and use it in GitHub Desktop.
Map plot for H-1B Shiny
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
require(ggmap) | |
require(ggrepel) | |
require(dplyr) | |
require(ggplot2) | |
USA = map_data(map = "usa") | |
# Layer 1: USA Map | |
ggplot(USA, aes(x=long, y=lat)) + | |
geom_polygon() + xlab("Longitude (deg)") + ylab("Latitude(deg)") + | |
# Layer 2: Point plot with bubble size directly proportional to metric and | |
# bubble transparency inversely proportional to metric | |
geom_point(data=map_df, aes_string(x="lon", y="lat", label = "WORKSITE", alpha = metric, size = metric), color="yellow") + | |
# Layer 3: Pointer to Top locations. Number of Top selected by Plot Categories Input of the App | |
geom_label_repel(data=map_df %>% filter(WORKSITE %in% top_locations),aes_string(x="lon", y="lat",label = "WORKSITE"), | |
fontface = 'bold', color = 'black', | |
box.padding = unit(0.0, "lines"), | |
point.padding = unit(1.0, "lines"), | |
segment.color = 'grey50', | |
force = 3) + | |
# USA Boundaries | |
coord_map(ylim = c(23,50),xlim=c(-130,-65)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment