Description Usage Format Details Source See Also Examples
Map data to plot the entire United States by transforming Alaska and Hawaii to appear as insets nearby the continental states.
1 |
A data frame with 13694 rows and 7 variables:
Numeric, latitude and longitude coordinates for shapes.
Integer, drawing order of shapes.
Logical, whether the shape represents a negation.
Factor, groupings of shapes.
Character, lower case state names mapped to plot data via
the map_id
aesthetic in geom_map
.
Factor, groupings of shapes.
The fifty_states
data frame is provided in the format
expected by the map
argument to geom_map
.
Border boxes for the inset states can be included by adding
fifty_states_inset_boxes
to the plot.
Original shapefile provided by Charlie Fitzpatrick via ArcGIS. Transformations based on code from Barry Rowlingson on StackOverflow http://stackoverflow.com/a/13767984.
1 2 3 4 5 6 7 8 9 10 | if(require("mapproj") && require("ggplot2")) {
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
p <- ggplot(crimes, aes(fill = UrbanPop, map_id = state)) +
geom_map(map = fifty_states) +
expand_limits(x = fifty_states$long, y = fifty_states$lat) +
coord_map()
p
# Add bounding boxes for Alaska and Hawaii
p + fifty_states_inset_boxes()
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.