Get the Books

Enjoying these notebooks and want to support the work? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books

How Do Degree Classes Vary By Graduates' Ethnicity?

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.


In [1]:
from plotapi import Terminus
import json

Terminus.set_license("your username", "your license key")


In this notebook we're going to use Plotapi Terminus to visualise how degree classes vary by graduates' ethnicity. We"ll use Python, but Plotapi can be used from any programming language.

In the Terminus diagram (a type of flow diagram), we can watch the journey of something or someone from some starting category to some ending category. In this case, we'll be watching each unit travel from a graduate's ethnicity to their awarded degree classification.


We're going to use data that has been published by the Higher Education Statistics Agency (HESA) in the UK. The data table is titled "UK domiciled first degree qualifiers by classification of first degree, religious belief, sex, age group, disability marker, ethnicity marker, mode of study and academic year" and it can be found at this link.

We will use data from all countries, all modes of study, and from the academic year 2019/20. "Other" and "Not known" have been combined.

The degree class is the result achieved by a student UK, similar to a Grade Point Average (GPA). You can find a mapping between UK degree classifications and GPA here

In [2]:
data = [
    {"source": "White", "target": "First class", "value": 92260},
    {"source": "White", "target": "Second class (upper)", "value": 114885},
    {"source": "White", "target": "Second class (lower)", "value": 29325},
    {"source": "White", "target": "Third class", "value": 4775},
    {"source": "White", "target": "Unclassified", "value": 12585},
    {"source": "Black", "target": "First class", "value": 4340},
    {"source": "Black", "target": "Second class (upper)", "value": 10640},
    {"source": "Black", "target": "Second class (lower)", "value": 6245},
    {"source": "Black", "target": "Third class", "value": 1555},
    {"source": "Black", "target": "Unclassified", "value": 750},
    {"source": "Asian", "target": "First class", "value": 11515},
    {"source": "Asian", "target": "Second class (upper)", "value": 17925},
    {"source": "Asian", "target": "Second class (lower)", "value": 7080},
    {"source": "Asian", "target": "Third class", "value": 1440},
    {"source": "Asian", "target": "Unclassified", "value": 2710},
    {"source": "Mixed", "target": "First class", "value": 4575},
    {"source": "Mixed", "target": "Second class (upper)", "value": 6740},
    {"source": "Mixed", "target": "Second class (lower)", "value": 2095},
    {"source": "Mixed", "target": "Third class", "value": 355},
    {"source": "Mixed", "target": "Unclassified", "value": 565},
    {"source": "Other/NA", "target": "First class", "value": 1415 + 1370},
    {"source": "Other/NA", "target": "Second class (upper)", "value": 2385 + 2350},
    {"source": "Other/NA", "target": "Second class (lower)", "value": 1065 + 1380},
    {"source": "Other/NA", "target": "Third class", "value": 190 + 985},
    {"source": "Other/NA", "target": "Unclassified", "value": 290 + 635}


Let's use Plotapi Terminus for this visualisation, you can see more examples in the Gallery.

We're going to adjust some layout and template parameters. We're setting percentage_by_source=True to see the degree class awarded as a percentage within ethnicity, i.e. each percentage column will sum to 100. We'll also set pixels_per_percentage=50 to control the length of the animation, making it shorter than the default of setting.

In [5]:
Terminus(data, width=1000, percentage_by_source=True, pixels_per_percentage=50,
         title="Watch graduate's collect their degree (by percentage within ethnicity)").show()

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

Plotapi, beautiful by default.

Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).

Get Plotapi