Skip to content

Instantly share code, notes, and snippets.

@abbhakan
Last active August 29, 2015 14:19
Show Gist options
  • Save abbhakan/b44a08407b783b8e47c9 to your computer and use it in GitHub Desktop.
Save abbhakan/b44a08407b783b8e47c9 to your computer and use it in GitHub Desktop.
Assignment 4
Country 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
Australia 414973.7 416477.89 420764.25 422801.08 423232.13 436863.96 443213.16 455692.63 470580.22 479616.71 489812.92 502347.13 503584.93 506235.37 519037.24 523479.26 529885.15 537930.78 544573.76 541177.63 540210.87 541542.76 543648.45
Austria 78086.35 82135.09 75410.77 75484.12 76345.45 79743.56 82754.78 82277.81 81653.02 79966.28 80276.96 84274.66 85975.57 91984.6 91569.35 92580.94 89710.79 86967.42 86882.03 80147.97 84807.85 82760.84 80059.36
Belgium 142952.13 144950.64 143694.93 142765.54 148485.04 150326.89 154307.66 145679.42 151211.31 144947.2 145856.88 145182.68 144717.56 145316.45 146397.6 142063.28 138341.86 133440.16 135823.29 123208.52 130610.94 120145.51 116520.32
Canada 590908.11 583211.91 600162.23 602008.18 622358.35 639072.03 661055.11 675981.97 683279.18 696158.27 721362.48 713949.96 719623.39 740178.7 743568.33 735829.05 727849.65 749288.91 731080.7 689313.24 699302.26 701212.37 698626.47
Czech Republic 196145.7 182192.75 165624.18 159466.81 149435.24 151773.53 155539.54 151816.23 144667.47 137106.75 146330.13 146326.41 142844.95 145827.26 147274.23 145965.05 147021.15 147245.85 142184.64 134205.66 137007.81 135276.54 131466.12
Denmark 70020.49 80532.19 74462.61 76641.83 80590.54 77280.44 90235.74 80739.74 76937.81 74271 69954.8 71548.51 70932.84 75837.35 69889.78 65588.79 73469.67 68920.42 65404.39 62511.41 63006.53 58051.67 53118.01
Estonia 40614.54 37439.42 27385.1 21251.03 21900.65 20064.37 20726.23 20331.52 18811.16 17450.52 17156.96 17542.39 16935.3 18810.48 19129.07 18421.21 17837.32 20948.75 19545.92 16188.5 19892.34 20483.96 19188.43
Finland 70328.96 68141.96 66720.51 68814.65 74204.2 70767.9 76491.71 75111.84 71531.01 70985.09 69188.4 74400.02 76624.5 84577.2 80583.77 68624.26 79900.3 78248.9 70126.26 66003.04 74397.39 66861.11 60965.73
France 560383.96 584125.17 574864.49 547997.28 548585.62 556875.45 571572.27 566289.54 581450.75 567058.44 564597.28 562987.91 557941.21 563354.03 561771.57 563576.88 551867.76 542720.66 537952.87 514380.38 522155.78 495981.68 496221.21
Germany 1248048.77 1201034.15 1150981.16 1141687.05 1121879.99 1117579.85 1136718.31 1100977.55 1075180.38 1041303.66 1040367.33 1055173.88 1033944.94 1032297.37 1019806.05 994459.68 1002426.45 976583.75 979802.7 912605.83 946388.27 928694.56 939083.31
Greece 104926.55 104525 105963.36 105049.8 107814.49 109717.66 112765.57 117585.67 123176.58 123027.51 126578.61 127510.38 127446.22 131257.18 131706.68 135310.59 131793.69 134636.56 130758.06 124109.98 117877.65 114728.07 110985.47
Hungary 97602.59 89744.26 79723.71 80262.61 79214.82 78474.71 80706.49 79269.91 79095.35 79687.63 76504.3 78359.24 76879.85 79604.12 79106.67 78376.04 77485.25 75650.65 73327.97 66975.65 67637.97 66034.09 61980.66
Iceland 3538.08 3373.69 3280.55 3342.65 3275.95 3315.39 3405.79 3559.14 3690.18 3919.17 3902.65 3869.83 3902.75 3878.58 3931.18 3859.26 4390.94 4619.47 5021.79 4779.27 4646.16 4441.13 4467.73
Ireland 55246.27 56017.48 56006.31 56322.71 57752.38 58903.21 61001.23 62510.37 65317.47 66281.89 68216.34 70207.5 68337.7 68467.13 68184.47 69655.66 69165.75 68370.74 68020.49 62312.26 61894.9 57749.96 58531.24
Italy 519054.9 520606.01 517782.73 511266.65 503551.64 530332.58 524037.79 530463.76 541857.68 548318.91 551237.06 557143.87 558301.69 573604.49 576843.08 574261.76 563373.42 555077.9 540620.5 490112.81 499358.6 486601.13 460083.45
Japan 1234320.12 1245823.29 1256111.75 1250768.52 1314837.52 1335888.27 1349668.79 1343308.19 1300747.04 1321896 1340522.55 1315673.33 1347823.81 1351663.74 1347639.97 1350321.36 1332532.63 1364257.69 1280903.32 1205672.64 1256094.69 1306517.93 1343117.72
Latvia 26212.92 24298.68 19568.81 15818.01 13893.49 12502.58 12517.29 11961 11437.09 10635.69 9993.58 10625.78 10604.55 10856.07 10852.07 11056.34 11522.36 11978.93 11496.15 10849.53 11987.43 11139.89 10978.48
Lithuania 48720.77 50105.04 30206.45 24301.31 22861.75 22072.26 23358.61 23055.05 23813.2 21255.73 19632.39 20716.15 21231.87 21447.71 22231.13 23318.5 23707.75 26119.08 24932.26 20431.63 21118.58 21679.98 21622.29
Luxembourg 12901.05 13446.77 13221.73 13333.88 12505.1 10177.49 10238.59 9534.45 8644.45 9062.37 9762 10258.25 11036.51 11381.76 12862.16 13095.2 12946.34 12360.72 12188.4 11683.85 12249.56 12124.93 11839.24
Netherlands 211849.59 216385.16 215098.97 219979.89 219933.69 223161.32 231327.16 224605.61 225494.05 213316.45 213023.12 214494.43 213544.38 214303.67 215514.09 209448.24 205558.92 204199.49 203313.53 197787.1 209286.43 195063.51 191668.7
New Zealand 60641.44 61615.13 62986.84 62644.42 63734.65 64464.84 66618.86 69138.05 67013.77 68979.31 70898.9 73619.06 74330.99 76807.65 76206.61 78286.62 78185.8 76221.51 75763.7 73101.16 73491.33 74393.45 76047.98
Norway 50409.35 48320.85 46573.39 48491.89 50447.41 50241.89 53377.75 53329.81 53502.03 54529.36 54058.49 55276.06 54140.02 54886.35 55438.48 54469.02 54288 56006.29 54424.51 51808.95 54346.96 53294.03 52733.24
Poland 466371.96 456203.77 442010.1 442072.58 438414.18 441102.72 454106.41 445808.23 416877.25 406496.5 396103.65 392886.22 380353.5 393407.05 398043.98 398827.04 414148.4 415449.44 406081.06 387700.41 407474.65 405741.44 399267.97
Portugal 60766.81 62683.22 67105.23 65821.06 66889.55 71398.88 69096.22 72159.32 77107.15 85223.52 84100.41 83872.45 88037.62 82327.79 85298.69 87685.99 82647.14 80269.39 78031.86 74853.97 70634.19 69316.55 68751.89
Russia 3363342.44 3186714.69 2698720.99 2561126.04 2291944.08 2207675.85 2144998.5 2039481.49 2003522.12 2036766.56 2053320.98 2078134.5 2080417.35 2118715.58 2152593.01 2135398.16 2201493.69 2206099.7 2245851.34 2130321.36 2221342.01 2284292.82 2295045.38
Slovak Republic 73226.77 63395.54 57780.37 54214.37 51801.73 53231.67 53658.4 52560.77 51859.38 50809.84 48947.36 51478.96 49919.34 50670.53 50933.1 50263.74 50317.6 48395.32 49001.04 44690.17 45382.46 44697.89 42710.2
Slovenia 18444.42 17320.7 17208.76 17450.39 17640.88 18548.59 19224.38 19585.6 19345.12 18693.85 18953.36 19819.74 19977.38 19672.15 19980.12 20313.71 20526.18 20671.8 21384.37 19373.15 19411.38 19462.56 18910.98
Spain 283749.23 293164.79 301709.76 291118.16 307473.16 322108.19 314841.92 328188.89 338022.05 364001.49 380004.18 376963.35 394905.23 402420.16 417194.61 431392.66 423788.78 432111.64 398444.15 359659.15 347181 345887.15 340808.59
Sweden 72713.85 72884.06 72412.49 72442.83 74898.45 74151.76 78017.33 72928.08 73396.87 70050.09 68562.87 69344.23 70067.57 70469.96 69698.88 66912.77 66778.43 65232.81 63013.87 59097.38 65071.97 60754.24 57604.15
Switzerland 52889.94 54607.28 54370.31 51594.95 50760.13 51575.62 52232.84 51318.61 52663.38 52679.67 51774.81 52804.53 51710.22 52835.35 53503.19 54209.49 53845.81 51910.3 53653.05 52366.48 54095.22 49973.23 51449.02
Turkey 188434.23 200654 211729.35 223080.22 218530.04 238820.28 259939.01 273172.46 275193.34 275905.57 298090.87 279074.9 287052.04 303537.09 313071.02 330740.34 350881.15 382378.4 368734.42 371149.35 403494.7 424090.95 439873.73
United Kingdom 778805.3 786300.13 762457.67 743586.13 733508.83 726758.05 748199.17 723818.76 722987.22 692181.89 693693.37 699212.55 680632.45 687042.24 684160.99 678252.8 675547.22 666079.29 646736 593379.87 609147.47 566268.75 584304.29
United States 6219524.02 6195074.54 6295803.99 6430339.4 6499923.37 6597665.21 6812323.32 6867121.18 6868760.62 6930957.16 7075609.42 6979196.38 7011195.7 7057538.8 7198378.99 7228293.16 7150743.56 7287750.12 7090753.13 6642319.59 6854728.19 6716993.02 6487847.05
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Greenhouse gas emissions</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
font-family: Helvetica, Arial, sans-serif;
}
h1 {
font-size: 24px;
margin: 0;
}
p {
font-size: 14px;
margin: 10px 0 0 0;
}
svg {
background-color: white;
}
circle:hover {
fill: red;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
</style>
</head>
<body>
<h1>Greenhouse gas emissions (1990 - 2012)</h1>
<p>Greenhouse gas emissions from 1990 - 2012 by OECD country. The unit is in houndred thousands tonnes of CO2 equivalent. Source: <a href="http://www.oecd-ilibrary.org/environment/data/oecd-environment-statistics/greenhouse-gas-emissions_data-00594-en">OECD</a>, 2015</p>
<script type="text/javascript">
var w = 700;
var h = 600;
var padding = [ 50, 10, 50, 100 ]; //Top, right, bottom, left
var year = "1990";
var year2 = "2012";
var xScale = d3.scale.linear()
.range([ padding[3], w - padding[1] - padding[3] ]);
var yScale = d3.scale.linear()
.range([ padding[0], h - padding[2] ]);
var xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom")
.ticks(15);
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left")
.ticks(15);
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
d3.csv("GreenhouseEmissions.csv", function(data) {
xScale.domain([
d3.min(data, function(d) {
return +d[year]/1000;
}),
d3.max(data, function(d) {
return +d[year]/1000;
})
]);
yScale.domain([
d3.max(data, function(d) {
return +d[year2]/1000;
}),
d3.min(data, function(d) {
return +d[year2]/1000;
})
]);
var circles = svg.selectAll("circle")
.data(data)
.enter()
.append("circle");
circles.attr("cx", function(d) {
return xScale(+d[year]/1000);
})
.attr("cy", function(d) {
return yScale(+d[year2]/1000);
})
.attr("r", 0.1)
.attr("fill", "green")
.append("title")
.text(function(d) {
return d.Country + "'s greenhouse gas emissions 1990 is " + d[year] + ", and 2012 " + d[year2] + "";
});
circles.sort(function(a, b) {
return d3.ascending(+a[year], +b[year]);
})
.transition()
.delay(function(d, i) {
return i * 50;
})
.duration(2000)
.attr("r", 4);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (h - padding[2] + 10) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + (padding[3] - 10) + ",0)")
.call(yAxis);
svg.append("text")
.attr("class", "x label")
.attr("text-anchor", "end")
.attr("x", w/2+100)
.attr("y", h)
.text("emissions (1990)");
svg.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("y", 6)
.attr("x", -(h/2-100))
.attr("dy", ".75em")
.attr("transform", "rotate(-90)")
.text("emissions (2012)");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment