Making a dot-density map with ggplot2
In your final exercise of this course, you are going to put together the datasets you've acquired and generated into a dot-density map with ggplot2. You'll plot your generated dots and ancillary datasets with geom_sf()
, and add some informative map elements to create a cartographic product.
This exercise is part of the course
Analyzing US Census Data in R
Exercise instructions
- Use
geom_sf()
to plot your simple features objects. - Plot water and roads features by specifying the objects you've created appropriately.
- Use the
caption
parameter inlabs()
to give your map an informative caption.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot your datasets and give your map an informative caption
___() +
___(___ = dc_boundary, color = NA, fill = "white") +
___(data = dc_dots, ___(color = group, fill = group), size = 0.1) +
___(data = ___, color = "lightblue", fill = "lightblue") +
___(data = ___, color = "grey") +
coord_sf(crs = 26918, datum = NA) +
scale_color_brewer(palette = "Set1", guide = FALSE) +
scale_fill_brewer(___ = "Set1") +
labs(title = "The racial geography of Washington, DC",
subtitle = "2010 decennial U.S. Census",
fill = "",
___ = "1 dot = approximately 100 people.\nData acquired with the R tidycensus and tigris packages.")