Visualization fundamentals

Materials from class on Wednesday, August 10, 2022

Contents

Session Outcomes

By the end of this homework session you should be able to:

  • Formally describe data graphics according to their visual encoding.
  • Reproduce graphics by writing ggplot2 specifications.
  • Combine dplyr and conditional statements to prep data for plotting.

Introduction

This homework requires you to apply the concepts and skills developed in the class session on visualization fundamentals.

Task 1: Describe and evaluate

Map of Butler Con-Lab Swing in 2019 General Election.

Figure 1: Map of Butler Con-Lab Swing in 2019 General Election.

Complete the description table below identifying each data item that is encoded along with its measurement level, visual mark and visual channel and the effectiveness rank, according to Munzner (2014), of this encoding.

Data item Measurement level Visual mark Visual channel Rank
location
... ... ... ... ...
... ... ... ... ...
... ... ... ... ...
... ... ... ... ...
... ... ... ... ...

Task 2: Reproduce

Histograms faceted by region

Write some code for reproducing something similar to the graphic below – a set of histograms of the Swing variable, faceted by region. Place your code into the 03-template.Rmd file for this session.

#######################
# Enter your code in the chunk provided.
######################
Histograms of Swing variable, grouped by region.

Figure 2: Histograms of Swing variable, grouped by region.

Scatterplots with multiple encodings

Write some code for reproducing something similar to the graphic below – a scatterplot comparing 2017 and 2019 vote shares for Labour. Be sure to include every encoding as it appears in the graphic (e.g. shape and alpha according to whether constituencies flipped allegiance). Hint: you may need to use a conditional statement to generate a variable for emphasising constituencies that flipped parties between 2017 and 2019. Place your code into the 03-template.Rmd file for this session.

#######################
# Enter your code in the chunk provided.
######################
Plots of 2019 versus 2017 vote shares.

Figure 3: Plots of 2019 versus 2017 vote shares.

Task 3: Create a map

Write some code for reproducing something similar to the graphic below – a map of the estimated Leave:Remain vote margin by Parliamentary Constituency. Note that I am using a diverging colour scheme here to distinguish whether the Constituency was majority Leave and Remain – brown or green – and also the size of that majority – the darker the colour, the larger the majority.

Place your code into the 03-template.Rmd file for this session.

#######################
# Enter your code in the chunk provided.
######################
Map of 2016 EU Referendum vote, estimated by Parliamentary Constituency in GB.

Figure 4: Map of 2016 EU Referendum vote, estimated by Parliamentary Constituency in GB.

References

Munzner, T. 2014. Visualization Analysis and Design. AK Peters Visualization Series. Boca Raton, FL: CRC Press.