Home Artificial Intelligence 5 Steps to Construct Beautiful Line Charts with Python

5 Steps to Construct Beautiful Line Charts with Python

0
5 Steps to Construct Beautiful Line Charts with Python

Learn how to use the complete capabilities of Matplotlib to inform a more compelling story

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

A couple of months back I wrote an article about bar charts and the way you may make them clear, self-explanatory, and visually pleasing to the audience to be able 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 price exploring.

Matplotlib makes it quick and simple to plot data with off-the-shelf functions however the fantastic 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 concept is to go from this…

… to that:

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

As an example 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 obligatory 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