[ad_1]
Easy methods to use the complete capabilities of Matplotlib to inform a extra compelling story
A couple of months again I wrote an article about bar charts and the way you can 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 can be price exploring.
Matplotlib makes it fast and simple to plot knowledge with off-the-shelf capabilities however the nice tuning steps take extra effort.
I spent fairly a while researching finest practices to construct compelling charts with Matplotlib, so that you don’t should.
The thought is to go from this…
… to that:
All photos, until in any other case famous, are by the writer.
For instance the methodology, I used a public dataset containing international locations’ GDP info over the previous 50 years:
Supply: World Financial institution nationwide accounts knowledge, and OECD Nationwide Accounts knowledge information.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’]…
[ad_2]
Source link