Building a complicated, layered graphic using the grammar of graphics

Application exercise
Modified

January 25, 2024

Important

This application exercise is ungraded. Graded application exercises begin next week.

library(tidyverse)

Carte figurative des pertes successives en hommes de l’Armée Française dans la campagne de Russie 1812–1813

Charles Minard’s 1869 chart showing the number of men in Napoleon’s 1812 Russian campaign army, their movements, as well as the temperature they encountered on the return path. Source: Wikipedia

Charles Minard’s 1869 chart showing the number of men in Napoleon’s 1812 Russian campaign army, their movements, as well as the temperature they encountered on the return path. Source: Wikipedia

English translation of Minard’s map. Source: Wikipedia

English translation of Minard’s map. Source: Wikipedia

This cartograph is identified in Edward Tufte’s The Visual Display of Quantitative Information as one of “the best statistical drawings ever created”. It also demonstrates a very important rule of warfare: never invade Russia in the winter.

In 1812, Napoleon ruled most of Europe. He wanted to seize control of the British islands, but could not overcome the UK defenses. He decided to impose an embargo to weaken the nation in preparation for invasion, but Russia refused to participate. Angered at this decision, Napoleon launched an invasion of Russia with over 400,000 troops in the summer of 1812. Russia was unable to defeat Napoleon in battle, but instead waged a war of attrition. The Russian army was in near constant retreat, burning or destroying anything of value along the way to deny France usable resources. While Napoleon’s army maintained the military advantage, his lack of food and the emerging European winter decimated his forces. He left France with an army of approximately 422,000 soldiers; he returned to France with just 10,000.

Charles Minard’s map is a stunning achievement for his era. It incorporates data across six dimensions to tell the story of Napoleon’s failure. The graph depicts:

  • Size of the army
  • Location in two physical dimensions (latitude and longitude)
  • Direction of the army’s movement
  • Temperature on dates during Napoleon’s retreat

What makes this such an effective visualization?1

  • Forces visual comparisons (colored bands for advancing and retreating)
  • Shows causality (temperature chart)
  • Captures multivariate complexity
  • Integrates text and graphic into a coherent whole (perhaps the first infographic, and done well!)
  • Illustrates high quality content (based on reliable data)
  • Places comparisons adjacent to each other (all on the same page, no jumping back and forth between pages)

Building Minard’s map in R

We can reconstruct this map using the grammar of graphics.2 Here we will focus just on the upper portion including the map depicting the troop movements.

troops <- read_table(file = "data/minard-troops.txt")
cities <- read_table(file = "data/minard-cities.txt")

troops
# A tibble: 51 × 5
    long   lat survivors direction group
   <dbl> <dbl>     <dbl> <chr>     <dbl>
 1  24    54.9    340000 A             1
 2  24.5  55      340000 A             1
 3  25.5  54.5    340000 A             1
 4  26    54.7    320000 A             1
 5  27    54.8    300000 A             1
 6  28    54.9    280000 A             1
 7  28.5  55      240000 A             1
 8  29    55.1    210000 A             1
 9  30    55.2    180000 A             1
10  30.3  55.3    175000 A             1
# ℹ 41 more rows
cities
# A tibble: 20 × 3
    long   lat city          
   <dbl> <dbl> <chr>         
 1  24    55   Kowno         
 2  25.3  54.7 Wilna         
 3  26.4  54.4 Smorgoni      
 4  26.8  54.3 Moiodexno     
 5  27.7  55.2 Gloubokoe     
 6  27.6  53.9 Minsk         
 7  28.5  54.3 Studienska    
 8  28.7  55.5 Polotzk       
 9  29.2  54.4 Bobr          
10  30.2  55.3 Witebsk       
11  30.4  54.5 Orscha        
12  30.4  53.9 Mohilow       
13  32    54.8 Smolensk      
14  33.2  54.9 Dorogobouge   
15  34.3  55.2 Wixma         
16  34.4  55.5 Chjat         
17  36    55.5 Mojaisk       
18  37.6  55.8 Moscou        
19  36.6  55.3 Tarantino     
20  36.5  55   Malo-Jarosewii

Exercise: Define the grammar of graphics for this graph

Recall the major elements of the grammar of graphics:

  • Layer
    • Data
    • Mapping
    • Statistical transformation (stat)
    • Geometric object (geom)
    • Position adjustment (position)
  • Scale
  • Coordinate system
  • Faceting

And here we have two data frames containing the following variables:

  • Troops
    • Latitude
    • Longitude
    • Survivors
    • Advance/retreat
  • Cities
    • Latitude
    • Longitude
    • City name

Use this information to define the grammar of graphics to recreate Minard’s map.3

Your answer here.