I'm trying to use ggplot2's map_data
to build a state level map. But when I call use the arguments "states" and plot it, the map doesn't fill in the entire US.
How do I get (1) map_data
to fill in the missing space and (2) show state lines?
library(ggplot2)
#**************** Get Map ******************
StateMap <- ggplot2::map_data("state")
#**************** Plot ******************
ggplot(StateMap, aes(x=long, y=lat)) +
geom_polygon()
This is what is produces:
Thank you for your help!
We have to add group
aesthetic to geom_polygon
:
library(ggplot2)
#**************** Get Map ******************
StateMap <- ggplot2::map_data("state")
#**************** Plot ******************
ggplot(StateMap, aes(x=long, y=lat, group = group)) +
geom_polygon(fill = "gray", color = "black")