Chart of the Week

A weekly series of quick random charts made in Python 🐍

The chart of this week is a horizontal bar chart from the article Almost 50 shops a day disappear from High Streets published in BBC.

Changing shopping behaviour

Data shows strong evidence of changing shopping behaviour and the shift to online. Fashion retailers recorded the biggest decline with more than 1000 stores closed in the first half of 2021. Charity shops, cars/motorbikes stores, betting shops and banks together also closed around 1500 stores in the same period.

On the other hand new stores, such as takeaway, cake shops, and convenience stores are opening. But the total of new stores is not even a 100.

import matplotlib.pyplot as plt
import pandas as pd


data = pd.DataFrame({
    'Type': ['Takeaways', 'Job centres', 'Convenience stores', 'Cake shops/patisseries', 'Amusement arcades',
             'Dept stores',
             'Catalogue shops', 'Travel agents', 'Funiture shops', 'Restaurants', 'Banks/financial services',
             'Betting shotps', 'Cars/Motorbikes', 'Charity shops', 'Fashion retailers'
             ],
    'Change': [54, 17, 9, 9, 8, -126, -127, -130, -135, -148, -286, -337, -428, -452, -1063]
})

color_positive = "#1380A1"  # 'blue'
color_negative = "#990000"  # 'red'
data['Color'] = data.Change.map(lambda x: color_positive if x >= 0 else color_negative)
data.sort_values('Change', inplace=True)

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

font_title = {'family': 'serif',
              'fontname': 'Charter',
              #        'color':  color_positive,
              'weight': 'bold',
              'size': 40,
              }

font_title_positive = {'family': 'serif',
                       'fontname': 'Charter',
                       'color': color_positive,
                       'weight': 'bold',
                       'size': 40,
                       }

font_title_negative = {'family': 'serif',
                       'fontname': 'Charter',
                       'color': color_negative,
                       'weight': 'bold',
                       'size': 40,
                       }

font_sub_title = {'family': 'serif',
                  'fontname': 'Charter',
                  'size': 30,
                  }

plt.text(x=0.05, y=0.9, s="              and                types of chain stores", ha="left",
         transform=fig.transFigure, fontdict=font_title)
plt.text(x=0.05, y=0.9, s="Growing", ha="left", transform=fig.transFigure, fontdict=font_title_positive)
plt.text(x=0.05, y=0.9, s="                     declining ", ha="left", transform=fig.transFigure,
         fontdict=font_title_negative)
plt.text(x=0.05, y=0.87, s="Great Britain, January to June 2021", ha="left", transform=fig.transFigure,
         fontdict=font_sub_title)

ax.spines['right'].set_visible(False)
ax.spines[['top', 'bottom']].set_visible(False)
ax.spines['left'].set_visible(False)

ax.tick_params(axis='y', direction='in', length=0, pad=50, labelsize=16)
ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)

ax.barh(data.Type, data.Change, color=data.Color)
ax.bar_label(ax.containers[0], padding=5, fontsize=16)

trans = ax.get_xaxis_transform()
ax.plot([0, 0], [0.04, 0.96], color="k", transform=trans, clip_on=False)
ax.plot([0.05, 0.95], [0.05, 0.05], color="black", clip_on=False, transform=fig.transFigure)

plt.text(x=0.05, y=0.025, s="Sources: PwC, BBC", fontsize=18, ha="left", transform=fig.transFigure)
plt.text(x=0.95, y=0.025, s="@QuantGirl", ha="right",
         transform=fig.transFigure,
         fontdict={'fontsize': 20, 'fontweight': 'bold', 'family': 'sans-serif', 'fontname': 'PT Serif Caption',
                   'color': '#a70684'
                   })

plt.subplots_adjust(top=0.85, bottom=0.05, left=0.35, right=0.90)

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.