*- 更改下部分国家的名字,方便与地图数据匹配 ren v1 country replace country = "The Bahamas"if country == "Bahamas" replace country = "Ivory Coast"if country == "Côte d'Ivoire" replace country = "Swaziland"if country == "Eswatini" replace country = "Guinea Bissau"if country == "Guinea-Bissau" replace country = "Federated States of Micronesia"if country == "Micronesia" replace country = "Republic of Serbia"if country == "Serbia" replace country = "United Republic of Tanzania"if country == "Tanzania" replace country = "East Timor"if country == "Timor-Leste" replace country = "Turkey"if country == "Türkiye" replace country = "United States of America"if country == "United States"
*- 历年碳排放 *- ssc install tidy gather _* replacevar = subinstr(var, "_", "", .) dropifvar == "merge" destringvar, replace dropif value == -1000 keep country var val country_cn renvar year ren val co2 save"历年各国人为碳排放量", replace
我们可以关注下碳排放量最高的 8 个国家的碳排放变化趋势:
*- 筛选最后一年排放量最高的 8 个国家 use 历年各国人为碳排放量, clear keepif year == 2020 gsort -co2 keepin 1/8 keep country merge 1:m country using 历年各国人为碳排放量 keepif _m == 3 drop _m gsort country year tw/// line co2 year if country == "China", lc("254 212 57") lp(solid) || /// line co2 year if country == "United States of America", lc("112 154 225") lp(solid) || /// line co2 year if country == "India", lc("138 145 151") lp(solid) || /// line co2 year if country == "Russia", lc("210 175 129") lp(solid) || /// line co2 year if country == "Indonesia", lc("253 116 70") lp(solid) || /// line co2 year if country == "Brazil", lc("213 228 162") lp(solid) || /// line co2 year if country == "Japan", lc("25 126 192") lp(solid) || /// line co2 year if country == "Iran", lc("240 92 59") lp(solid) ||, /// leg(order(1 "中国" 2 "美国" 3 "印度" 4 "俄罗斯" 5 "印度尼西亚"/// 6 "巴西" 7 "日本" 8 "伊朗")) /// xla(1990(5)2020) xti("") /// yti("CO2排放量(百万吨)") /// ti("2020 年部分国家人为 CO2 排放量(百万吨)") /// subti("数据处理 & 绘图:微信公众号 RStata") /// caption("数据来源:Greenhouse Gas (GHG) Emissions | Climate Watch")
gr export "2020 年部分国家人为 CO2 排放量(百万吨).png", width(4800) replace
再分析下各个国家的占比:
use 历年各国人为碳排放量, clear gsort -co2 dropif co2 == -1000 keepif year == 2020 egentotal = total(co2) keepin 1/10 egen total2 = total(co2) gen other = total - total2 set obs 11 replace country = "Others"in 11 replace country_cn = "其他国家"in 11 replace year = 2020 in 11 replace co2 = other[1] in 11
评论