Skip to content
Field Guide
Coming soon. This video isn't public yet. Everything it says is in the transcript below.

A publication figure, in Python and R

Under-five mortality for every country, in Python and in R.

1:46 Captions in the video Python R Recorded 16 October 2026

Lesson 5 of 5 · Present it in the tools you use The last lesson of this course

Try it yourself

  • Python, after import undata as un
    un.style()
    table = un.latest("undata/sdg/SH_DYN_MORT.AGE--Y0T4", "World", since=2020)
    table["region"] = table.iso3.map(un.countries().set_index("iso3").region)
    un.save(table, "under5.csv")                      # for R, Stata or Excel

Remember: One house style for every figure, and a CSV for colleagues who work in R or Stata.

Transcript

  1. 0:00 When a figure goes into a flagship report, it has to survive layout, translation and print. Here is how to build one in Python, and the same one in R, from a single table.
  2. 0:10 Every country is a dot, grouped by region, a form the Atlas uses often. The dashed line is the SDG target: no more than twenty-five deaths before age five, per thousand live births. Orange marks the 66 countries above it, 45 of them in Africa.
  3. 0:27 un.style gives matplotlib undata’s report defaults: the fonts, the light grid, the export settings. Get each country’s latest value since 2020, add its region from the UN’s M49 list, and save a CSV for colleagues who work in R or Stata. Then one short loop draws a row of dots per region, the target line, and a title that counts, rather than one you type. Saved as SVG, the text stays editable for the design team.
  4. 0:54 Your team works in R? Read the same CSV with readr. ggbeeswarm spreads the dots so none sit on top of each other, and the title counts the same way. The source line comes from the file itself, because un.save put it on every row.
  5. 1:09 Two languages, one table, and the same answer: 66 of 199. When both agree, you know the number came from the data, not from the code. Half the countries in Africa are above 48; in Europe, the middle country is under 4.
  6. 1:24 Call un.style once at the top. Let the title count, so it is never out of date. Take the source from the data. And hand the designers an SVG, not a screenshot.
  7. 1:34 Five products, five everyday tools, one habit: every number keeps its source. That is undata at work.

Go deeper

↑ ↓ to move · Enter to open · A match inside a video opens the lesson at the moment the words are said.