Chart of the Week

A weekly series of quick random charts made in Python 🐍

The chart of this week is a pie chart from the article Gaming’s Old Guard Isn’t Losing Sleep Over Netflix or Amazon by Bloomberg Opinion.

Gaming Diversity

According to Newzoo, the global games market is expected to grow from $\$176$ billion this year to $\$219$ billion by 2024 with nearly 3 billion people around the world playing games today. Mobile devices account for about half of the 2021 games market revenue

Video Games Revenue sources in 2021.
import numpy as np
import pandas as pd
from matplotlib import gridspec
from matplotlib import pyplot as plt

# Author: @QuantGirl
# Source: Bloomberg IG
# https://www.instagram.com/p/CRwE-JvgDA6/
# Type: Pie Chart

data = pd.DataFrame({'revenue': ['Mobile', 'Console', 'PC', 'Tablet'], 'percentage': [45, 28, 20, 7]})

labels = ['45% Mobile', '28% \n Console', '20% PC', '7% Tablet']

fig = plt.figure(figsize=(10, 10))
gs1 = gridspec.GridSpec(1, 1,
                        left=0.1, right=0.7,
                        bottom=0.1, top=0.7,
                        )
gs2 = gridspec.GridSpec(1, 1,
                        left=0.05, right=0.95,
                        bottom=0.9, top=1.0,
                        )

pie_ax = fig.add_subplot(gs1[0])
title_ax = fig.add_subplot(gs2[0])

colors = ['dodgerblue', 'Black', 'silver', 'tomato']

wedges, texts = pie_ax.pie(
    data['percentage'],
    shadow=False,
    colors=colors,
    counterclock=False,
    startangle=90,
    radius=1
)

bbox_props = dict(boxstyle="square,pad=0.3", fc="w", ec="k", lw=0.9)
kw = dict(xycoords='data', textcoords='data', arrowprops=dict(arrowstyle="-"), zorder=0, va="center")

for i, p in enumerate(wedges):
    ang = (p.theta2 - p.theta1) / 2. + p.theta1
    y = np.sin(np.deg2rad(ang))
    x = np.cos(np.deg2rad(ang))
    horizontalalignment = {-1: "right", 1: "left"}[int(np.sign(x))]
    connectionstyle = "angle,angleA=0,angleB={}".format(ang)
    kw["arrowprops"].update({"connectionstyle": connectionstyle, "color": "Black"})
    pie_ax.annotate(labels[i], xy=(x, y), xytext=(1.15 * np.sign(x), 1.2 * y),
                    horizontalalignment=horizontalalignment, **kw)

pie_ax.text(-1.5, -1.3, 'Source: Bloomberg Opinion', fontdict={'fontsize': 12,
                                                               'fontweight': 'bold', 'family': 'sans-serif',
                                                               'fontname': 'American Typewriter',
                                                               'color': 'Black'})

pie_ax.text(0.8, -1.3, '@QuantGirl',
            fontdict={'fontsize': 14,
                      'fontweight': 'bold', 'family': 'sans-serif',
                      'fontname': 'American Typewriter',
                      'color': 'purple'})

pie_ax.axis('equal')
title_ax.set_facecolor('white')

title_ax.text(0.4, -1, "Nearly half of video games revenue \n comes from smartphones",
              fontdict={'fontsize': 22, 'fontweight': 'bold',
                        'fontname': 'Arial',
                        },
              ha="center", va="center", transform=title_ax.transAxes, color="Black")

for side in ['top', 'bottom', 'left', 'right']:
    title_ax.spines[side].set_visible(False)
    title_ax.axes.get_xaxis().set_visible(False)
    title_ax.axes.get_yaxis().set_visible(False)

plt.savefig(r"Figures/PieChart.png",bbox_inches="tight")
plt.show()
Quant Girl

I write about Mathematics, Statistics, Finance, Programming, and the relationships among them. I enjoy learning, listening to music and podcasts, practicing yoga, reading magazines, and watching documentaries.

Leave a Reply

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