Annual Military Spending

The chart of this week is a treemap of the military spending around the world. The data is from the Stockholm International Peace Research Institute (SIPRI) Military Expenditure Database which is based on open sources.

🔷 The world military expenditure was $1,981 billion in 2020, an increase of 2.6% on 2019 in real terms.

🔷 The top 5 spenders in 2020 were the United States, China, India, Russia and the United Kingdom, which together accounted for 62% of world military spending.

🔷 Military expenditure by the top 15 countries reached $1,603 billion in 2020 and accounted for 81% of global military spending.

🔷 Note that on February 27, 2022, in response to the ongoing escalation of the Russo-Ukrainian War, Germany announced a extraordinary expenditure bump to 100 billion Euro or 112bn USD, up from 47.31bn Euro or 52.8bn USD, as estimated by SIPRI, putting them at the 3rd largest on the planet. 

Python Code

Python modules required: matplotlib, pandas, and squarify.

# Author: @Quant_Girl
# Title: Military Expenditure
# Source: STOCKHOLM INTERNATIONAL PEACE RESEARCH INSTITUTE
# Type: Treemap

import matplotlib.pyplot as plt
import pandas as pd
import squarify

df = pd.DataFrame({'Spend': [778, 378.0,
                             252, 72.9,
                             61.7, 59.2,
                             57.5, 52.8,
                             52.7, 49.1,
                             45.7, 28.9,
                             27.5, 22.8,
                             21.7, 19.7],

                   'Country': ["USA\n$778 bn", "All Others\n$279 bn",
                               "China \n$252 bn", "India \n$72.9 bn",
                               "Russia\n$61.7 bn", "UK\n$59.2 bn",
                               "Saudi Arabia\n$57.5 bn", "Germany\n$52.8 bn",
                               "France\n$52.7 bn", "Japan\n$ 49.1 bn",
                               "S. Korea\n$45.7 bn", "Italy\n$28.9 bn",
                               "Australia\n$27.5 bn", "Canada\n$22.8 bn",
                               "Israel\n$22 bn", "Brazil\n$19.7 bn",
                               ],
                   'Color': ['#B1C9FD', '#FFAEBC',
                             '#B99095', '#D9A21B',
                             '#DDF6FF', '#A0E7E5',
                             '#748067', '#f79256',
                             '#fbd1a2', '#B99095',
                             '#F1F1E6', '#fbd1a2',
                             '#B5E5CF', '#B1C9FD',
                             '#748067', '#B5E5CF',
                             ]})

df.sort_values('Spend', ascending=False, inplace=True)

fig, ax = plt.subplots(figsize=(9, 9), frameon=True)

squarify.plot(sizes=df['Spend'], label=df['Country'], alpha=.7,
              color=df['Color'], pad=True,
              ax=ax)

# Title and Subtitle
ax.text(x=0.5, y=0.93, s="Military Expenditure", fontsize=14, fontweight="bold", ha="center",
        transform=fig.transFigure)
ax.text(x=0.5, y=0.90, s="Countries with the highest military expenditure in 2020", fontsize=12, ha="center",
        transform=fig.transFigure)

# Footnotes
ax.text(x=0.13, y=0.07, s="Source: Stockholm International Peace Research Institute (SIPRI)\nFact Sheet April 2021. ",
        fontsize=10, ha="left",
        transform=fig.transFigure)

ax.text(x=0.9, y=0.07, s="@Quant_Girl", ha="right",
        transform=fig.transFigure,
        fontdict={'fontsize': 10, 'fontweight': 'bold', 'family': 'sans-serif', 'fontname': 'PT Serif Caption',
                  'color': '#ff7096'
                  })

plt.axis('off')
plt.show()

A weekly series of quick random charts made with Python 🐍

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
%d bloggers like this: