Last active
October 8, 2022 11:09
-
-
Save hbshrestha/45c2c5bac513c1ba6a2f807fc107ef24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gases = ["CO$_2$", "CH$_4$", "N$_2$O", "F-gases"] | |
warming_potential = [1, 25, 300, 1000] | |
text_height = [i*1.2 for i in warming_potential] | |
text = ["1", "25", "300", "1000+"] | |
volume = [74.4, 17.3, 6.2, 2.1] | |
colors = ["brown", "darkslategray", "darkgray", "purple"] | |
fig, (ax1, ax2) = plt.subplots(1, 2) | |
ax1.bar(gases, warming_potential, color = colors) | |
for i, height, word in zip(range(4), text_height, text): | |
ax1.text(x = i * 0.9, y = height, s = word) | |
ax1.set_yscale("log") | |
ax1.set_title("Global warming potential (GWP)\n by gas over 100-year timescale", y = 1) | |
ax1.spines.top.set_visible(False) | |
ax1.spines.right.set_visible(False) | |
autopct = lambda p:f'{p:.1f}%' | |
ax2.pie(x = volume, radius = 1, startangle = 90, labels = gases, | |
autopct = autopct, pctdistance = 0.8, colors = colors, textprops = {"color":"white"}) | |
ax2.legend(labels = gases, bbox_to_anchor = (0.9, 0.8), ncol = 1) | |
ax2.set_title("Atmospheric composition of global \nGHG emissions", y = 1.1) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment