To understand visualizations effectively, it’s important to be familiar with the anatomy of a plot. In this text, we will discuss some of the fundamental parts of a plot, acquainting you with the terminology that will be extensively used throughout this course.

To get going, we first need a plot to focus on. We’ll use a simple plot of horsepower versus fuel consumption from the mtcars dataset.

To produce the plot, simply run the following code.

library(tidyverse)

mtcars %>%
  mutate(cyl = as.factor(cyl)) %>%
  ggplot(aes(hp, mpg, color = cyl)) +
  geom_point() +
  labs(
    x = "Horsepower",
    y = "Fuel Consumption (miles per US gallon)",
    color = "Cylinders"
  )

1 The Canvas

The canvas, also called the plot area, is the area where the data is drawn. Everything outside of the canvas consists of annotations, which usually do not display data directly.

If you use facets in your plot, your visualization might contain several canvases. We’ll discuss facets in detail later, but for now, it’s sufficient to think of facets as multiple plots arranged in sequence, one after the other.

2 Grid

Sometimes, as in the default ggplot2 theme, the canvas is divided into sections by a grid. A grid often makes it easier to compare data points, especially when they are far apart. Grids are particularly useful when there are few observations in a visualization.

Grids often have major and minor gridlines, and this plot is no exception, although the difference between them is slight.

3 Geoms

The geoms in the plot are geometrical shapes that are used to draw data. Here, we are using points as our geoms.

4 Axes

The axes are guides for the connection between the coordinates of the geoms and the variables they are mapped to. Without the axes, we would only see the pattern of points and not the values these points represent.

On each axis, there are numbers or words, and these are connected to the gridlines through ticks or tickmarks .

5 Legends

A legend is a guide that helps you interpret an aesthetic element mapped to a variable in the plot. In this plot, the legend associates a color scale with the number of cylinders.

The legend is sometimes also called a key.

6 Guide Titles

The guide titles describe the variables and often the units for the data.