fortify.map | R Documentation |
This function turns a map into a data frame that can more easily be plotted with ggplot2.
## S3 method for class 'map'
fortify(model, data, ...)
model |
map object |
data |
not used by this method |
... |
not used by this method |
map_data
and borders
if (require("maps")) {
ca <- map("county", "ca", plot = FALSE, fill = TRUE)
head(fortify(ca))
ggplot(ca, aes(long, lat)) +
geom_polygon(aes(group = group))
tx <- map("county", "texas", plot = FALSE, fill = TRUE)
head(fortify(tx))
ggplot(tx, aes(long, lat)) +
geom_polygon(aes(group = group), colour = "white")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.