Home Artificial Intelligence 5 Steps to Construct Beautiful Line Charts with Python Motivation #0 The Data

5 Steps to Construct Beautiful Line Charts with Python Motivation #0 The Data

0
5 Steps to Construct Beautiful Line Charts with Python
Motivation
#0 The Data

How you can use the total capabilities of Matplotlib to inform a more compelling story

Towards Data Science
GDP Evolution over time of the 5 richest countries — Image by Creator

A number of months back I wrote an article about bar charts and the way you possibly can make them clear, self-explanatory, and visually pleasing to the audience with a purpose to tell a more compelling story (link below).

In this text I look into line charts as an alternative, which produce other specificities which are value exploring.

Matplotlib makes it quick and straightforward to plot data with off-the-shelf functions however the positive tuning steps take more effort.

I spent quite a while researching best practices to construct compelling charts with Matplotlib, so that you don’t must.

The thought is to go from this…

… to that:

All images, unless otherwise noted, are by the creator.

For instance the methodology, I used a public dataset containing countries’ GDP information over the past 50 years:

Source: World Bank national accounts data, and OECD National Accounts data files.
License URL: https://datacatalog.worldbank.org/public-licenses#cc-by
License Type: CC BY-4.0

After importing the essential packages to read the information and construct our graphs, I simply filtered on the Top 20 countries of 2022:

import pandas as pd
import matplotlib.pyplot as plt
from datetime import timedelta

# Read the information
df = pd.read_csv('88a1e584-0a94-4e73-b650-749332831ef4_Data.csv', sep=',')
df.drop(['Series Name', 'Series Code', 'Country Code']…

LEAVE A REPLY

Please enter your comment!
Please enter your name here