Visualizations and the grammar of graphics
Overview
- 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
Before class
- Read chapters 1-4 from R for Data Science
- Chapters 1, 2, and 4 are very short but set the stage for the next few weeks
- Chapter 3 is crucial - you need to read this chapter and complete some of the exercises before coming to class. Exercise solutions can be found here.
- Read The grammar of graphics
- If you have additional time, also read/skim A Layered Grammar of Graphics
- Install and setup software
- Definitely have R and RStudio installed and operational for class today
- If you haven’t gotten GitHub setup yet, that’s fine but you will need it to complete homework 1
Class materials
Exploring Minard’s 1812 plot with
ggplot2
- a much fancier (and more complex) version
Additional resources
Graphical design
- Tufte, Edward R. The Visual Display of Quantitative Information. Classic book on statistical graphics and visualization design.
- Healey, Kieran. Data Visualization: A Practical Guide. An applied introduction to graphical design with lots of applications in
ggplot2
(and many code examples).
ggplot2
- ggplot2: Elegant Graphics for Data Analysis, 2nd Edition – Hadley Wickham. Excellent resource for learning the intricacies of
ggplot2
. - Documentation for ggplot2
- R Graphics Cookbook, 2nd edition – Winston Chang. A practical guide with 150 examples to generate quality statistical graphics based on the data you wish to present.
- Why do we learn the
ggplot2
graphics library and not the basegraphics
system? David Robinson explains it well in Don’t teach built-in plotting to beginners (teach ggplot2), and follows up with a longer defense ofggplot2
in Why I use ggplot2
Useful cheatsheets
- Data visualization with ggplot2 cheat sheet
- RStudio IDE Cheat Sheet - if you don’t know what all the buttons and panels do in RStudio, this is a great decoder
What you need to do after class
- Complete the first homework assignment
- If you installed your software locally, install the
rcis
library from GitHub. To install the package, run the commandremotes::install_github("cis-ds/rcis")
in the console. We will be using data from this package in class next week.
If you do not already have the
remotes
library installed, you will get an error. Go back and install this first using install.packages("remotes")
, then run remotes::install_github("cis-ds/rcis")
in the console.