ggplot2 (version 3.3.0)

fortify.map: Fortify method for map objects

Description

This function turns a map into a data frame that can more easily be plotted with ggplot2.

Usage

# S3 method for map
fortify(model, data, ...)

Arguments

model

map object

data

not used by this method

...

not used by this method

See Also

map_data() and borders()

Examples

Run this code
# NOT RUN {
if (require("maps")) {
ca <- map("county", "ca", plot = FALSE, fill = TRUE)
head(fortify(ca))
ggplot(ca, aes(long, lat)) +
  geom_polygon(aes(group = group))
}

if (require("maps")) {
tx <- map("county", "texas", plot = FALSE, fill = TRUE)
head(fortify(tx))
ggplot(tx, aes(long, lat)) +
  geom_polygon(aes(group = group), colour = "white")
}
# }

Run the code above in your browser using DataCamp Workspace