A walkthrough of making a ggplot figure
Practicing ggplot by replicating an Economist figure
This is a walkthrough of making a ggplot figure, replicating an Economist figure. After learning how to make a ggplot call, define our aesthetics, and add different geoms, it still takes a lot of practice to put them together into a figure. This exercise is meant to help you practice putting together a figure from start to finish by replicating a figure from the Economist. One of the most important lessons to learn is that no one can remember all the options and syntax for ggplot, so you will need to look up the documentation and examples to figure out how to do what you want. In the video below, you’ll see me doing this as I work through the figure.
- First, read the original article, “Economic growth does not guarantee rising happiness”
- Then, download the two data files, gdp_happiness_points.csv and gdp_happiness_paths.csv. These are slightly modified versions of the files from the Economist’s GitHub.
- Finally, follow along with the video, which shows me making the figure, explaining what I’m doing, and what I do when I get an error or don’t know how to do something.