87  The Grammar of Graphics

The first step in thinking creatively about data visualisation is to appreciate that graphics are built upon an underlying grammar. When we write a manuscript, we take great care to form our sentences so that they communicate the specific message we want to convey. That is what we need to do with graphics.

We are not limited to specific, standard, forms of expression. Indeed, we can, and should, communicate in the way that best suits our goal.

87.1 Graphics have a Grammar

We now have all the elements necessary to start building meaningful plots using the grammar of graphics plotting concept. Just as every word in a sentence has a clear grammatical definition, so to does every element of a graphic. Consider one of the most well-known sentences in English:

Figure 87.1: The components of English grammar – word choice conveys meaning, grammar permits understanding.

Maintaining the structure of the original sentence, replacing specific words dramatically changes the meaning.

We build graphics in much the same way. 1The grammatical elements of our graphics are:

  • 1 To highlight the relationship between language and visual grammar, I have colour-coded each element. This is for illustrative purposes only and should not be dwelled on to literally.

    • Data The data-set being plotted. Aesthetics The scales onto which we map our data.

    • Geometries The visual elements used for our data.

    • Statistics Representations of our data to aid understanding.

    • Coordinates The space on which the data will be plotted.

    • Facets Plotting small multiples.

    • Themes All non-data ink.

    This concept will be explored throughout the rest of the workshop. We will make use of the structure depicted in figure @ref(fig:GrammarGraphics), which lists some attributes that we have already encountered in the workshop.

    Figure 87.2: The 7 layers in the grammar of graphics provides the basic layout for the Grammar of Graphics plotting concept.