Choropleth Maps in ggplot2
How to make Choropleth Maps in ggplot2 with Plotly.
New to Plotly?
Plotly is a free and open-source graphing library for R. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
County-Level Boundaries
library(plotly)
library(maps)
county_df <- map_data("county")
state_df <- map_data("state")
# create state boundaries
p <- ggplot(county_df, aes(long, lat, group = group)) +
geom_polygon(colour = alpha("black", 1/2), fill = NA) +
geom_polygon(data = state_df, colour = "black", fill = NA) +
theme_void()
fig <- ggplotly(p)
fig