Figure Friday 2025-w28

Corruption Perception Index (CPI): compare regions and countries

The Corruption Perceptions Index (CPI) is an index that scores and ranks countries by their perceived levels of public sector corruption, as assessed by experts and business executives.The CPI generally defines corruption as an “abuse of entrusted power for private gain”. The index is published annually by the non-governmental organisation Transparency International since 1995.

Since 2012, the Corruption Perceptions Index has been ranked on a scale from 100 (very clean) to 0 (highly corrupt). (Source: Wikipedia)

Idea & approach

The dataset contains CPI scores and rankings for most countries worldwide. A higher score corresponds to a better ranking, with rank 1 going to the country perceived as the least corrupt. The countries are grouped into regions, though in my view, some of these regional classifications are not entirely intuitive.

My approach was twofold:

  • To allow users to view countries with similar scores grouped together or in close sequence.
  • To offer insight into how different regions compare to one another.

I deliberately avoided extensive filtering options.

While rankings are useful for communication and marketing purposes, they are less informative analytically. For example, if every country had a score of 40, they would all share rank 1—despite 40 being on the more corrupt side of the spectrum. A rank of 1 sounds impressive, but a score of 40 tells a different story.

I initially experimented with a world map, where countries were colored based on their CPI score for 2024. However, I eventually decided not to use it. What the map, or rather the median score of 40 on the color scale, illustrates is that fewer countries are perceived as reasonably or highly trustworthy (based on the data) compared to the number of countries associated more closely with corruption.

CPI scores 2024 op wereldkaart

Result

The app opens with a bar chart that shows, by region, how many countries fall into each CPI score category. Everything is clearly organized per region, and you can toggle regions on or off by clicking them.

When you click on a part of a bar, usually for the region you’re interested in, a popup appears with a table. This table shows:

  • which countries fall within that specific CPI score range,
  • their global ranking,
  • and a small chart displaying their scores from 2012 to 2024.

Demo

Py.cafe: demo & code

Community link: link

Example includes:

  • Filtering data via a bar chart.
  • A popup with a Dash AG Grid. The grid contains a custom column that generates a sparkline based on historical data.
  • DBC Bootstrap and dark/light mode support for everything except the sparkline.

Figure Friday is an initiative by the Dash/Plotly community, where each Friday a new dataset is shared and participants create a visualization or small app to extract insights from it. The following Friday at 18:00, there’s a Zoom session where some participants explain the thought process behind their work. In the community thread, people also share their code — and when possible, a live demo — to learn from each other.