Chapter 3 Basic data visualization

3.1 Types of plots and visual variables

Different types of plot (known as geom in ggplot2) can be used depending on the structure of the data, namely the number of variables and whether the variables are discrete or continuous.

Figure 3.1: Different types of plot (known as geom in ggplot2) can be used depending on the structure of the data, namely the number of variables and whether the variables are discrete or continuous.

Visual variables, proposed by Jacques Bertin in 1967, namely visual elements that can be changed to reflect different attributes of the data. For example, different colours (which is essentially value + hue) can be used to represent different countries in the context of COVID-19 statistics. Image taken from https://www.axismaps.com/guide/general/visual-variables/

Figure 3.2: Visual variables, proposed by Jacques Bertin in 1967, namely visual elements that can be changed to reflect different attributes of the data. For example, different colours (which is essentially value + hue) can be used to represent different countries in the context of COVID-19 statistics. Image taken from https://www.axismaps.com/guide/general/visual-variables/

3.2 ggplot2 and grammar of graphics

Structure of a ggplot, which includes (i) specifying the data (red), (ii) specifying the mapping of columns to aesthetics (gold), (iii) defining geoms i.e. the type of plot (blue), (iv) defining how scales i.e. axis labels / colour palettes are displayed and (v) providing changes to visual themes (grey).

Figure 3.3: Structure of a ggplot, which includes (i) specifying the data (red), (ii) specifying the mapping of columns to aesthetics (gold), (iii) defining geoms i.e. the type of plot (blue), (iv) defining how scales i.e. axis labels / colour palettes are displayed and (v) providing changes to visual themes (grey).

Number of daily COVID-19 cases, coloured by type (confirmed / death / recovered) in Singapore. Dots reflect actual numbers while lines represent 7-day rolling averages.

Figure 3.4: Number of daily COVID-19 cases, coloured by type (confirmed / death / recovered) in Singapore. Dots reflect actual numbers while lines represent 7-day rolling averages.

7-day rolling averages of the number of daily COVID-19 cases for selected countries, coloured by country. The x-axis is adjusted to show the number of days since more than 50 total cases are confirmed in the corresponding country.

Figure 3.5: 7-day rolling averages of the number of daily COVID-19 cases for selected countries, coloured by country. The x-axis is adjusted to show the number of days since more than 50 total cases are confirmed in the corresponding country.

3.3 More plots to explore!