Created
September 25, 2015 20:55
-
-
Save jowang0319/75274174cfdb526195de to your computer and use it in GitHub Desktop.
week5:scatter plot
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
country | infantMortalityRate | primaryCompletionRate | |
---|---|---|---|
Algeria | 23.5 | 92.51422882 | |
Angola | 109.6 | 40.14783859 | |
Antigua and Barbuda | 7.7 | 101.913269 | |
Arab World | 32.28170265 | 82.6985321 | |
Argentina | 13 | 108.2583084 | |
Austria | 3.6 | 98.25421143 | |
Azerbaijan | 33.9 | 88.97885132 | |
Bahamas, The | 11.4 | 94.85346985 | |
Bangladesh | 39.2 | 70.49899292 | |
Barbados | 13.6 | 105.7491302 | |
Belgium | 3.6 | 92.26545715 | |
Belize | 16.3 | 106.4534378 | |
Benin | 71 | 55.96918106 | |
Bhutan | 34.1 | 96.35308838 | |
Bolivia | 36.8 | 93.15220642 | |
Brunei Darussalam | 7.7 | 107.7526398 | |
Bulgaria | 11.2 | 105.6320572 | |
Burkina Faso | 69.7 | 44.06893921 | |
Burundi | 63.8 | 49.01374054 | |
Cabo Verde | 23.3 | 99.34114075 | |
Cambodia | 36.7 | 91.68153381 | |
Cameroon | 66.2 | 64.20378876 | |
Caribbean small states | 18.79682905 | 93.10451508 | |
Central African Republic | 101.7 | 30.18457031 | |
Central Europe and the Baltics | 6.746707521 | 97.32325745 | |
Chad | 93.6 | 23.49278069 | |
Colombia | 15.9 | 114.7272415 | |
Congo, Dem. Rep. | 84.8 | 54.9679184 | |
Congo, Rep. | 42.2 | 67.22634888 | |
Costa Rica | 8.9 | 96.96784973 | |
Croatia | 4.6 | 91.38627625 | |
Cuba | 4.9 | 98.75244904 | |
Cyprus | 3 | 100.8589172 | |
Czech Republic | 3.4 | 108.9190521 | |
Denmark | 3.3 | 99.38253021 | |
Dominica | 17.2 | 81.2397995 | |
Dominican Republic | 27.9 | 90.24506378 | |
East Asia & Pacific (all income levels) | 18.21170719 | 104.9947891 | |
East Asia & Pacific (developing only) | 19.2 | 105.3598938 | |
Ecuador | 21.3 | 102.9539413 | |
Egypt, Arab Rep. | 24.3 | 104.3540802 | |
El Salvador | 17.1 | 95.06249237 | |
Equatorial Guinea | 78.9 | 52.63772964 | |
Estonia | 3.6 | 95.33157349 | |
Euro area | 3.648834541 | 99.43891907 | |
Europe & Central Asia (all income levels) | 11.81721227 | 98.18402863 | |
Europe & Central Asia (developing only) | 21.6 | 97.7919693 | |
European Union | 4.307984234 | 98.63733673 | |
Finland | 2.5 | 98.33461761 | |
Fragile and conflict affected situations | 63.47283877 | 63.00351334 | |
Gambia, The | 51.7 | 74.75131226 | |
Georgia | 14.9 | 115.7588501 | |
Germany | 3.5 | 101.2165985 | |
Greece | 4.1 | 100.1779633 | |
Grenada | 11.9 | 103.2128525 | |
Guatemala | 28.4 | 83.1153183 | |
Guinea | 71.2 | 47.99417114 | |
Guinea-Bissau | 73.4 | 56.68780136 | |
Guyana | 33.5 | 94.93670654 | |
Heavily indebted poor countries (HIPC) | 62.77097202 | 60.06468582 | |
High income | 6.6 | 98.66924286 | |
High income: nonOECD | 12.12297896 | 99.07261658 | |
High income: OECD | 4.67132275 | 98.5482254 | |
Honduras | 20.7 | 101.2355728 | |
Hungary | 5.7 | 97.97763824 | |
Iceland | 1.9 | 96.57407379 | |
Iran, Islamic Rep. | 16.4 | 103.7376785 | |
Israel | 3.7 | 102.1928177 | |
Italy | 3.4 | 102.0077362 | |
Japan | 2.4 | 100.7415771 | |
Kazakhstan | 19.3 | 102.8035431 | |
Korea, Rep. | 3.5 | 99.34158325 | |
Kyrgyz Republic | 26.5 | 96.63749695 | |
Lao PDR | 59 | 80.04451752 | |
Latin America & Caribbean (all income levels) | 17.94407555 | 99.55323792 | |
Latin America & Caribbean (developing only) | 19 | 99.40028381 | |
Latvia | 8.2 | 93.99823761 | |
Least developed countries: UN classification | 60.45701568 | 62.68008804 | |
Lebanon | 8.7 | 85.45307922 | |
Lesotho | 75.2 | 83.16015625 | |
Liechtenstein | 106.6350708 | ||
Lithuania | 5.6 | 104.6726608 | |
Low & middle income | 42 | 89.70928192 | |
Low income | 63 | 60.56679916 | |
Lower middle income | 47.4 | 89.37412262 | |
Luxembourg | 1.9 | 84.83126831 | |
Madagascar | 42.1 | 71.21040344 | |
Malawi | 57.5 | 69.04071045 | |
Mali | 82.9 | 54.84397888 | |
Malta | 5.6 | 92.55635834 | |
Mauritius | 13.3 | 103.2394791 | |
Mexico | 14.4 | 93.99691772 | |
Middle East & North Africa (all income levels) | 23.06400438 | 90.55309296 | |
Middle East & North Africa (developing only) | 24.4 | 89.31517792 | |
Middle income | 37.4 | 94.43700409 | |
Moldova | 14.7 | 92.65367889 | |
Morocco | 28.5 | 81.36979675 | |
Mozambique | 71.9 | 55.10712814 | |
Myanmar | 45.8 | 96.7735672 | |
Namibia | 37.5 | 84.64054108 | |
Nicaragua | 22 | 83.41893768 | |
Niger | 66.1 | 35.13595963 | |
Nigeria | 81.5 | 71.52314758 | |
Norway | 2.6 | 99.28981018 | |
OECD members | 7.157264734 | 97.92749023 | |
Other small states | 52.34126856 | 78.68188477 | |
Pacific island small states | 24.06919415 | 97.89498901 | |
Pakistan | 73.5 | 60.26723862 | |
Panama | 17 | 92.00022888 | |
Paraguay | 20.4 | 91.25849152 | |
Peru | 16.3 | 99.42054749 | |
Poland | 5 | 95.08609009 | |
Romania | 12.1 | 94.20201874 | |
Rwanda | 43.8 | 56.17655945 | |
Samoa | 16 | 106.3937378 | |
San Marino | 3.1 | 107.2847672 | |
Sao Tome and Principe | 39.8 | 92.48233795 | |
Senegal | 46.7 | 59.05258179 | |
Serbia | 6.6 | 96.60488129 | |
Slovak Republic | 7 | 101.559082 | |
Slovenia | 2.7 | 96.07079315 | |
Small states | 44.94544617 | 83.22514343 | |
South Asia | 49.8 | 89.69166565 | |
Spain | 3.9 | 102.5851898 | |
Sri Lanka | 9.4 | 98.58200073 | |
St. Kitts and Nevis | 10 | 88.65545654 | |
St. Vincent and the Grenadines | 18.6 | 91.5860672 | |
Sub-Saharan Africa (all income levels) | 65.95886707 | 64.56603241 | |
Sub-Saharan Africa (developing only) | 65.8 | 64.57215118 | |
Sudan | 53.3 | 54.22645187 | |
Swaziland | 59.1 | 77.93898773 | |
Sweden | 2.5 | 96.4311676 | |
Switzerland | 3.9 | 97.53890228 | |
Syrian Arab Republic | 13.2 | 103.6311188 | |
Tajikistan | 44.7 | 99.74043274 | |
Tanzania | 42.4 | 91.73339081 | |
Timor-Leste | 53.1 | 64.73622131 | |
Togo | 59.3 | 61.80672836 | |
Trinidad and Tobago | 21 | 94.9871521 | |
Tunisia | 14.9 | 101.6530685 | |
Turkey | 16.4 | 99.48298645 | |
Uganda | 49.5 | 54.80828094 | |
Ukraine | 10.1 | 98.89807129 | |
United Arab Emirates | 7.3 | 96.26954651 | |
Upper middle income | 18.9 | 102.92276 | |
Uruguay | 10.6 | 103.9940109 | |
Uzbekistan | 39.6 | 90.97830963 | |
Vanuatu | 23.9 | 86.75198364 | |
Venezuela, RB | 14.3 | 94.65075684 | |
West Bank and Gaza | 20.2 | 91.8777771 | |
World | 37.5 | 90.90634918 | |
Yemen, Rep. | 42.4 | 54.44889832 | |
Zambia | 52.9 | 105.4886475 |
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
<!DOCTYPE html> | |
<!-- A modified example from Scott Murray's Knight d3 course. --> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Formatting Ticks</title> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script> | |
<style type="text/css"> | |
body { | |
background-color: white; | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
.wrapper { | |
margin: auto; | |
width: 700px; | |
margin-top:50px; | |
} | |
h1 { | |
font-size: 28px; | |
margin: 0; | |
} | |
p { | |
font-size: 15px; | |
margin: 10px 0 0 0; | |
} | |
svg { | |
background-color: white; | |
} | |
circle:hover { | |
fill: rgba(51,51,153,0.5); | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: black; | |
shape-rendering: crispEdges; | |
} | |
.axis text { | |
font-family: sans-serif; | |
font-size: 11px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrapper"> | |
<h1>Does Female Education Help Decreasing the Infant Mortality Rate?</h1> | |
<p><strong>Introduction:</strong> | |
Educated girls tend to marry later, and to have a better and healthier family. Bellow shows the relationship between the completion of primary school of women and the infant mortality rate.</p> | |
<p><strong>Source: </strong><a href="http://data.worldbank.org/">World Bank</a>, 2010</p> | |
<div id = "svg"></div> | |
<script type="text/javascript"> | |
var width = 700; | |
var height = 600; | |
var margin = {top:20,right:10,bottom:50,left:50}; | |
var dotRadius = 6; | |
var xScale = d3.scale.linear() | |
.range([ margin.left, width - margin.right - margin.left ]); | |
var yScale = d3.scale.linear() | |
.range([ height - margin.bottom, margin.top ]); | |
var xAxis = d3.svg.axis() | |
.scale(xScale) | |
.orient("bottom") | |
.ticks(5); | |
var yAxis = d3.svg.axis() | |
.scale(yScale) | |
.orient("left") | |
.ticks(6); | |
var svg = d3.select("#svg") | |
.append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.csv("data.csv", function(data) { | |
xScale.domain( | |
d3.extent(data, function(d) { | |
return + d.infantMortalityRate; | |
})); | |
yScale.domain( | |
d3.extent(data, function(d) { | |
return + d.primaryCompletionRate; | |
})); | |
var circles = svg.selectAll("circle") | |
.data(data) | |
.enter() | |
.append("circle"); | |
circles.attr("class","dots") | |
circles.attr("cx", function(d) { | |
return xScale(d.infantMortalityRate); | |
}) | |
.attr("cy", function(d) { | |
return yScale(d.primaryCompletionRate); | |
}) | |
.attr("r", dotRadius) | |
.attr("fill",function(d){ | |
if (d.country === "World"){ | |
return "rgba(255,0,153,0.5)"; | |
} else { | |
return "rgba(0,153,255,0.5)"; | |
} | |
}) | |
.append("title") | |
.text(function(d) { | |
return d.country + "'s infant mortality rate is " + d.infantMortalityRate + ", and its female primary school completion rate is" + d.primaryCompletionRate; | |
}); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + (height - margin.bottom) + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.attr("transform", "translate(" + margin.left + ",0)") | |
.call(yAxis) | |
.selectAll("text") | |
.attr("transform","rotate(-50)") | |
.attr("dy","-.8em") | |
.attr("dx",".5em"); | |
svg.append("text") | |
.attr("x", width/2 ) | |
.attr("y", height - 10 ) | |
.style("text-anchor", "middle") | |
.text("Infant Mortality Rate"); | |
svg.append("text") | |
.attr("y", 0 ) | |
.attr("x", - height/2) | |
.style("text-anchor", "middle") | |
.text("Female Primary School Completion Rate") | |
.attr("transform", "rotate(-90)") | |
.attr("dy", "1em"); | |
}); | |
</script> | |
</div><!-- wrapper --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment