import os
from pathlib import Path
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# data directory
data_dir = Path(os.path.abspath("../data/processed/"))
data_file = data_dir / "unfccc-ghg-without-lulucf-1990-2021.csv"
# load data
df = pd.read_csv(data_file)
df.loc[df['year'] == 2021].sort_values(by='emissions_gt',ascending=False)[0:10]
party | year | emissions_gt | |
---|---|---|---|
1407 | United States of America | 2021 | 6.340228 |
383 | European Union (Convention) | 2021 | 3.468394 |
1119 | Russian Federation | 2021 | 2.156599 |
671 | Japan | 2021 | 1.168094 |
479 | Germany | 2021 | 0.760358 |
191 | Canada | 2021 | 0.670428 |
1311 | Türkiye | 2021 | 0.564390 |
1375 | United Kingdom of Great Britain and Northern I... | 2021 | 0.429489 |
447 | France | 2021 | 0.420061 |
639 | Italy | 2021 | 0.417591 |
top10 = list(df.loc[df['year'] == 2021].sort_values(by='emissions_gt',ascending=False)[0:10]['party'])
for party in top10:
data = df.loc[df['party'] == party]
plt.plot(data['year'], data['emissions_gt'], label=party)
plt.xlabel('Year')
plt.ylabel('Emissions (gigatonne)')
plt.legend(title='Country', bbox_to_anchor=(1.05, 1), loc='upper left')
<matplotlib.legend.Legend at 0x137b26600>