Data Visualization and Maps II
Content for Wednesday, November 29, 2023
R
provides a number of different packages for generating plots of your data, but ggplot2
is probably the most common owing to its ability to use consistent syntax to produce a variety of different graphics. In addition to plots of data and model objects, ggplot2
can also be used with sf
objects and some raster datasets to generate publication quality maps. We’ll also take a little more time to understand some of the options for building static maps in R
and look at a few packages that can help you build publication-quality maps without having to move into a new software.
Resources
The Data Visualization: A Practical Introduction by (Healy 2018) provides a lot of examples of Tufte-style graphics built with
ggplot2
.Graphic design with ggplot2 is an entire course devoted to making beautiful visualizations with
ggplot2
. If nothing else, check out some of the examples!The
patchwork
package website provides a lot of examples of building complicated layouts withggplot2
objects with intuitive syntax.The Drawing Beautiful Maps Programatically with
R
,sf
, andggplot2
chapter by Mel Moreno and Mathieu Basille provides a nice series of blogposts designed to help you build maps withsf
objects.Creating beautiful demographic maps in
R
with thetidycensus
andtmap
packages by Zev Ross illustrates the simplicity of mapping withtmap
.Displaying time series, spatial and space-time data with R by Oscar Perpiñán Lamigueiro has a bunch of interesting code for producing maps contained in the book by the same name.
Objectives
By the end of today you should be able to:
Understand the relationship between the Grammar of Graphics and
ggplot
syntaxDescribe the various options for customizing
ggplot
s and their syntactic conventionsGenerate complicated plot layouts without additional pre-processing
Construct a map using
ggplot2
andtmap
Combine vector and raster data in the same map