Cédric Scherer (link) has written a delightful guide to ggplot. His post is titled A ggplot2 Tutorial for Beautiful Plotting in R (link).
I worked through his post by looking at some of the data from the FIFA Women’s World Cup in France (link) earlier this year.
My exploration of Cédric’s suggestions was definitely of the trial and improvement kind. I did find it one of the best introductory guides to ggplot I have discovered and it helped me build on my eclectic learning journey with this form of visualisation.
The csv file I used for this exploration is available on GitHub (link) and is titled RefereesWWC.csv. My brief R record is:
I looked at five examples from the official FIFA data provided in FIFA’s Match Facts (link). I was mindful that the median ball in play time during the World Cup was 55 minutes and the median time was 97 minues.
1. A geom_point of the referees who officiated at the World Cup and the FIFA record of ball in play time in minutes.
2. A geom_line and geom_point development of visualisation 1 that connects referees that officiated at more than one game at the World Cup.
3. A geom_density_ridges visualisation of ball in play time and total game time.
4. A generative additive model for less than 1000 data points. An outlier, USA v Thailand, is recorded with annotate.
5. An example of a developed geom_density-ridges plot that used the theme_economist visualisation backdrop from the
ggridges package. It uses temperature data to look at goals scored in the tournament.
This visualisation provides an opportunity to record with annotation particular games and includes two 0v0 games, the 13 v 0 game and two games involving six goals.
I do recommend Cédric’s post unreservedly. It is a great way for us to develop our use of ggplot as a visualisation tool. The basic code I used for my post is available on a GitHub (link).