Code Monkey home page Code Monkey logo

safeskies's Introduction

Recreating an Economist graph from scratch using ggplot

This is a weekend exercise. Our objective is to reproduce an Economist graph found on the article: Safe Skies. The Economist article came in light of the MH370 incident, and argued that despite the recent tragedy, air flights are getting safer.

The Challenge

Because we are reproducing a graph from scratch, this project involves the collection of data from the original sources. However, since the primary objective of this exercise is concerned with the use of ggplot2 and the various techniques in generating an Economist-like graph, I have compiled the data into a dataset, aviation.csv, which is included in the repo. Our approach in recreating the Economist graph will be as follow:

  1. Read and process the dataset
  2. Load the 'ITC Officina' fonts installed on our system showtext library
  3. Create a ggplot2 theme, called theme_safeskies, that will be used for our graph
  4. Create a textGrob using the grid library
  5. Create a digit transformation function
  6. Create the underlying barchart without applying the theme
  7. We add (3), (4), (5) onto the barchart we created in (6) to produce an identical replication of the Economist graph

Project structure

The project is completed using R notebook, and exported to both HTML and PDF. All three files (Rmd, HTML and PDF) along with the dataset I've prepared, aviation.csv, are available in this repo. At the end of the exercise, I have attempted to re-create the original graph from scratch using only the vanilla ggplot library (without the use of ggthemes or other theming library) and in the process showed how we can create a custom theme for our own projects.

safeskies's People

Contributors

onlyphantom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.