Visualizations and the grammar of graphics
Learning objectives
- Identify the importance of graphics in communicating information
- Define the layered grammar of graphics
- Demonstrate how to use layered grammar of graphics to build Minard's graph of Napoleon's invasion of Russia
- Practice generating layered graphics using
ggplot2
April 8, 2020
Lecture Notes
The important of data visualization
- Really helpful sometimes to visualize the data rather than to just observe the raw data
Grammar
- Must obey the rules of grammer to form a coherent language
- Grammar of Graphics: "The fundamental principles or rules of an art or science"
ggplot2
uses this grammar in R -> layered grammar of graphics
Example: Minard's map
- Utilizes line and color
- Can we define this visualization using the grammar of graphics?
Building Minard's map in R
troops
and cities
data frames representing different kinds of information
- Minard's grammar: troops (latitude, longitude, survivors, advance/retreat), cities (latitude, longitude, city name)
- layer, scale, coordinate system, faceting
Building Minard's map in R solutions on the CFSS website
- Layer defines all the major visual elements
- Scale allows us to change the asethetic appearance of those elements