Get startedGet started for free

The grammar of graphics

1. The grammar of graphics

The first step in thinking creatively about data visualization is to appreciate that graphics are built upon an underlying grammar.

2. The quick brown fox jumps over the lazy dog

To begin, let's consider one of the most well-known sentences in English. The quick brown fox jumps over the lazy dog.

3. The quick brown fox jumps over the lazy dog

Every word in the sentence has a clear grammatical definition and when we write text, we take great care to choose the grammatical elements so that we communicate a very specific message. If we changed any of the grammatical elements of this sentence it would change the meaning, sometimes subtly, sometimes dramatically.

4. Grammar of graphics

The same concept holds true for data visualization - graphics are built on an underlying grammar. The grammar of graphics is a plotting framework developed by Leland Wilkinson and published in his 1999 book, *The Grammar of Graphics*. There are two key things to note about the grammar of graphics. First, graphics are made up of distinct layers of grammatical elements, and second, meaningful plots are built around appropriate aesthetic mappings. To continue our analogy to written grammar, the layers are like the adjectives and nouns and the aesthetic mappings are like the grammatical rules for how to assemble that vocabulary.

5. The three essential grammatical elements

Let's explore grammatical elements first. There are three essential grammatical elements: data, aesthetics, and geometries. The data is obviously the data which we want to plot. the aesthetics layer refers to the scales onto which we will map our data, and the geom layer refers to the actual shape the data will take in the plot.

6. Course 1: core competency

The rest are optional layers. This includes the theme layer, which controls all the non-data ink. In this course, we'll cover these first four layers which will comprise your core competency.

7. The seven grammatical elements

In the next course we'll explore the remaining grammatical elements: the statistics, coordinates and facets layers.

8. Jargon for each element

This diagram gives an example of some of the terms we'll encounter in each element. Whenever we make a plot we are choosing among these options and many others not displayed. By the end of this course you'll be able to generate meaningful and publication-quality exploratory plots using the first four layers.

9. Course 2: Tools for EDA

Once we've covered the remaining three layers in the second course, we'll be using data viz as a tool for exploratory data analysis.

10. Let's practice!

Let's head over to the exercises and explore one of the datasets that you'll be using throughout the two courses.