Last active
November 5, 2015 12:19
-
-
Save atbradley/2900282b45b1b4550596 to your computer and use it in GitHub Desktop.
Generate a state map using choroplethr and add custom-formatted labels.
This file contains hidden or 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
c = StateChoropleth$new(df_state_demographics) | |
c$title = "Population by State, Percent Black" | |
c$set_num_colors(7) | |
c$show_labels = F | |
df_state_labels = data.frame(long = state.center$x, lat = | |
state.center$y, name=tolower(state.name), label = state.abb) | |
df_state_labels = df_state_labels[!df_state_labels$name %in% c("alaska", | |
"hawaii"), ] | |
d <-c$render() + | |
geom_text(data = df_state_labels, | |
aes(long, lat, label = label, group = NULL), | |
color = gray(.1), size=4) | |
print(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment