Income Inequality

Return to Data Art Gallery.

D3


Code
function monoPlot(data) {
  
    const margin = 20;
    const width = 500;
    const height = 500;
    const bgCol = "#9D1B69";

    const xScale = d3.scalePow()
        .domain([-4, 4])
        .range([ 0, width - 2*margin])
        .exponent(0.5); 

    const yScale = d3.scalePow()
        .domain([-13, 13])
        .range([ height - 2*margin, 0])
        .exponent(0.5);
    
    const alphaScale = d3.scaleLinear()
        .domain([0, 25])
        .range([0, 1]);

    // Plot
    const chartContainer = d3.select("#chart")
      .style('background-color', bgCol);
  
    const svg = chartContainer
      .append("svg")
      .attr("viewBox", `0 0 ${width} ${height}`)
      .attr("preserveAspectRatio", "xMidYMid meet")
      .style("width", "100%")
      .style("height", "auto")
      .append("g")
      .attr("transform", "translate(" + margin + "," + margin + ")");

    svg.selectAll('circle')
        .data(data)
        .enter()
        .append('circle')
        .attr("cx", function (d) { return xScale(d.ChangeA); } )
        .attr("cy", function (d) { return yScale(d.ChangeB); } )
        .attr('r', d => 4 * d.Continent)
        .attr('fill', "#F0A8D3")
        .attr('stroke', "#F0A8D3")
        .attr('fill-opacity', function (d) { return alphaScale(d.Income); });
  
  };

  d3.csv("data.csv", d => ({
    Income: +d.Income,
    ChangeA: +d.ChangeA,
    ChangeB: +d.ChangeB,
    Continent: +d.Continent
  }))
  .then(data => {
    monoPlot(data);
  });

Our World in Data is an online publication and research organisation that provides comprehensive, data-driven insights on global issues, such as health, education, poverty, and environment. It aims to make complex global trends accessible by visualising data through interactive charts and research. The share of income received by the richest 1% of the population, can be used as a measure of economic inequality. Income here is measured before taxes and benefits.

Each circle represents a different country. This scatterplot shows the change between 2023 and 2022 on the x-axis, and the change between 2023 and 2015 in the y-axis. As expected, the changes are smaller over one year. The transparency shows the overall percentage of income received by the richest 1%, and the size relates to the continent the country is in.

Return to Data Art Gallery.