How one can use the total capabilities of Matplotlib to inform a extra compelling story
![Towards Data Science](https://miro.medium.com/v2/resize:fill:48:48/1*CJe3891yB1A1mzMdqemkdg.jpeg)
Just a few months again I wrote an article about bar charts and the way you might make them clear, self-explanatory, and visually pleasing to the viewers as a way to inform a extra compelling story (hyperlink under).
On this article I look into line charts as an alternative, which produce other specificities which are price exploring.
Matplotlib makes it fast and straightforward to plot information with off-the-shelf capabilities however the nice tuning steps take extra effort.
I spent fairly a while researching greatest practices to construct compelling charts with Matplotlib, so that you don’t should.
The concept is to go from this…
… to that:
All photographs, until in any other case famous, are by the creator.
As an instance the methodology, I used a public dataset containing international locations’ GDP data over the previous 50 years:
Supply: World Financial institution nationwide accounts information, and OECD Nationwide Accounts information recordsdata.License URL: https://datacatalog.worldbank.org/public-licenses#cc-byLicense Kind: CC BY-4.0
After importing the required packages to learn the info and construct our graphs, I merely filtered on the High 20 international locations of 2022:
import pandas as pdimport matplotlib.pyplot as pltfrom datetime import timedelta
# Learn the datadf = pd.read_csv(’88a1e584-0a94-4e73-b650-749332831ef4_Data.csv’, sep=’,’)df.drop([‘Series Name’, ‘Series Code’, ‘Country Code’]…