%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use("ggplot")
from pandas_datapackage_reader import read_datapackage
from shortcountrynames import to_name
emissions = read_datapackage("https://github.com/openclimatedata/global-carbon-budget", "territorial-emissions")
emissions.head()
Emissions | Source | ||
---|---|---|---|
Code | Year | ||
ABW | 1959 | 0.196 | CDIAC |
1960 | 0.169 | CDIAC | |
1961 | 0.176 | CDIAC | |
1962 | 0.193 | CDIAC | |
1963 | 0.185 | CDIAC |
emissions = emissions.drop("Source", axis=1)
unit = "MtC"
ax = emissions.loc["CHN"].plot()
emissions.loc["USA"].plot(ax=ax)
plt.legend([to_name("CHN"), to_name("USA")])
plt.ylabel(unit);
consumption = read_datapackage("https://github.com/openclimatedata/global-carbon-budget", "consumption-emissions")
consumption.head()
Consumption-Emissions | ||
---|---|---|
Code | Year | |
ALB | 1990 | 1.533 |
1991 | 1.246 | |
1992 | 0.775 | |
1993 | 0.718 | |
1994 | 0.626 |
unit_consumption = "MtC"
parties = ["USA", "CHN"]
for code in parties:
ax = consumption.loc[code].plot()
emissions.loc[code].plot(ax=ax)
assert unit == unit_consumption
plt.title(to_name(code))
plt.ylabel(unit)