Annotations
Make sure to set inherit.aes = FALSE
and show.legend = FALSE
“A quick and dirty way to get map data (from the maps package) on to your plot.”
borders <- function(database = "world", regions = ".", fill = NA,
colour = "grey50", ...) {
df <- map_data(database, regions)
geom_polygon(
aes_(~long, ~lat, group = ~group),
data = df, fill = fill, colour = colour, ...,
inherit.aes = FALSE, show.legend = FALSE
)
}
library(maps)
data(us.cities)
capitals <- subset(us.cities, capital == 2)
ggplot(capitals, aes(long, lat)) +
borders("world", xlim = c(-130, -60), ylim = c(20, 50)) +
geom_point(aes(linewidth = pop)) +
scale_size_area() +
coord_quickmap()