Skip to content

Reproducible Figures

You'll write a script that turns raw data into five finished charts in one house style, so a data update is one command and not an evening of clicking.

About

The fourth time you rebuild a chart by hand because the numbers changed, you'll want this badge. A charting script reads the raw file, cleans it, draws every figure in one style and exports them at print quality, and it does the same thing every time. Free options are matplotlib or Plotly in Python, ggplot2 in R, Vega-Lite as JSON, or Observable Plot in JavaScript, and the language doesn't matter as long as you can rerun it. You'll share the script, the five figures it draws, and a rerun after the data changed. Charts exported from a spreadsheet by hand don't count here, however nice they are, and the programming itself lives in Coding.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
Three weekends
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
With other people
Locked for now
Earn two more Uncommon badges in Data Visualization to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Set up one folder with raw data, a script and an output folder, and get one plain chart out the other end. Raw files are never edited by hand; the script reads them and writes to the output folder. Delete the output, run the script, and check the chart comes back. Take a screenshot of the folder tree and the first chart. Photo
  2. 2
    Write a theme once, with fonts, a palette, gridlines and sizes, and apply it to every chart from one place. ggplot2 has theme(), matplotlib has rcParams and style sheets, Vega-Lite has a config block. Put your palette card from Color on Purpose in it if you have one. Changing the font in one place should change it everywhere. Take a screenshot of the theme code and two charts that share it. Photo
  3. 3
    Produce five different chart types from the script, each with a finding as its title and a source line drawn by the code. A bar, a line, a scatter, a distribution and one of your choice, each with a subtitle that gives the unit. Titles are data too, so compute the number in the title from the data rather than typing it in. Take a screenshot of the five side by side. Photo
  4. 4
    Export every figure as both SVG or PDF and a 300 dpi PNG, sized for where it'll be used. Vector for print and the web, raster for slides and feeds. Set the width in centimetres or inches, not pixels, so the text ends up the size you intended. Open the SVG in Inkscape, which is free, and check the text is still text. Take a screenshot of the output folder with the file sizes visible. Photo
  5. 5
    Change the raw data, rerun with one command, and show every figure update. Add a month of rows or fix a value, run the script, and open the outputs. If anything needs a manual step, script it. Film the rerun from the command to the new charts. Video
  6. 6
    Put the script and the data in a public repository or shared folder with a README, and have someone else run it. One command and one sentence of setup is the target. If a friend can't produce your charts from your README on their machine, fix the README, not the friend. Take a screenshot of their output with their name or their machine visible. Photo