# Plot continuous state level data:
data(df_state_demographics)
state_choropleth(df = df_state_demographics,
geoid.name = 'region',
geoid.type = 'name.lower',
value.name = 'population',
title = "U.S. State Population",
legend = "Population")
# Plot categorical data with custom colors:
data("df_president")
state_choropleth(df = df_president,
geoid.name = 'region',
geoid.type = 'name.lower',
value.name = 'value',
title = "2012 US Presidential Election Results",
legend = "Candidate",
custom.colors = c('blue4', 'red3'),
border_color = 'lightgrey')
# Label states and pass additional arguments to ggrepel
state_choropleth(df = df_president,
geoid.name = 'region',
geoid.type = 'name.lower',
value.name = 'value',
title = "2012 US Presidential Election Results",
legend = "Candidate",
custom.colors = c('blue4', 'red3'),
border_color = 'lightgrey',
label = 'state.abb',
label_text_size = 4,
ggrepel_options = list(label.r = 0, force = 0.02))
# Use a styled hexagonal tile map instead of actual state shapes:
state_choropleth(df = df_president,
style = 'hexgrid',
projection = 'mercator',
geoid.name = 'region',
geoid.type = 'name.lower',
value.name = 'value',
title = "2012 US Presidential Election Results",
legend = "Candidate",
custom.colors = c('blue4', 'red3'),
border_color = 'lightgrey',
label = 'state.abb',
label_text_size = 3)
Run the code above in your browser using DataLab