Skip to content

Instantly share code, notes, and snippets.

@krisfed
Last active February 10, 2017 15:36
Show Gist options
  • Save krisfed/bad0ad3ee0834f0301fe80aa94393645 to your computer and use it in GitHub Desktop.
Save krisfed/bad0ad3ee0834f0301fe80aa94393645 to your computer and use it in GitHub Desktop.
COMPSCI590V: Data Visualization And Exploration - Educational Attainment in the United States: 2015 - Education Heatmap by age and gender
license: mit
age number level
..18 to 24 years 39 None
..18 to 24 years 46 1st - 4th grade
..18 to 24 years 40 5th - 6th grade
..18 to 24 years 85 7th - 8th grade
..18 to 24 years 159 9th grade
..18 to 24 years 298 10th grade
..18 to 24 years 1,727 11th grade /2
..18 to 24 years 4,068 High school graduate
..18 to 24 years 5,692 Some college, no degree
..18 to 24 years 381 Associate's degree, occupational
..18 to 24 years 577 Associate's degree, academic
..18 to 24 years 1,684 Bachelor's degree
..18 to 24 years 148 Master's degree
..18 to 24 years 7 Professional degree
..18 to 24 years - Doctoral degree
..25 to 29 years 15 None
..25 to 29 years 44 1st - 4th grade
..25 to 29 years 75 5th - 6th grade
..25 to 29 years 93 7th - 8th grade
..25 to 29 years 126 9th grade
..25 to 29 years 155 10th grade
..25 to 29 years 379 11th grade /2
..25 to 29 years 2,403 High school graduate
..25 to 29 years 2,137 Some college, no degree
..25 to 29 years 543 Associate's degree, occupational
..25 to 29 years 674 Associate's degree, academic
..25 to 29 years 3,106 Bachelor's degree
..25 to 29 years 893 Master's degree
..25 to 29 years 127 Professional degree
..25 to 29 years 113 Doctoral degree
..30 to 34 years 15 None
..30 to 34 years 52 1st - 4th grade
..30 to 34 years 96 5th - 6th grade
..30 to 34 years 111 7th - 8th grade
..30 to 34 years 190 9th grade
..30 to 34 years 162 10th grade
..30 to 34 years 342 11th grade /2
..30 to 34 years 2,364 High school graduate
..30 to 34 years 1,886 Some college, no degree
..30 to 34 years 509 Associate's degree, occupational
..30 to 34 years 751 Associate's degree, academic
..30 to 34 years 2,672 Bachelor's degree
..30 to 34 years 1,216 Master's degree
..30 to 34 years 168 Professional degree
..30 to 34 years 163 Doctoral degree
..35 to 39 years 34 None
..35 to 39 years 55 1st - 4th grade
..35 to 39 years 198 5th - 6th grade
..35 to 39 years 135 7th - 8th grade
..35 to 39 years 189 9th grade
..35 to 39 years 115 10th grade
..35 to 39 years 313 11th grade /2
..35 to 39 years 2,335 High school graduate
..35 to 39 years 1,631 Some college, no degree
..35 to 39 years 428 Associate's degree, occupational
..35 to 39 years 718 Associate's degree, academic
..35 to 39 years 2,386 Bachelor's degree
..35 to 39 years 1,163 Master's degree
..35 to 39 years 163 Professional degree
..35 to 39 years 223 Doctoral degree
..40 to 44 years 41 None
..40 to 44 years 50 1st - 4th grade
..40 to 44 years 178 5th - 6th grade
..40 to 44 years 183 7th - 8th grade
..40 to 44 years 155 9th grade
..40 to 44 years 130 10th grade
..40 to 44 years 316 11th grade /2
..40 to 44 years 2,333 High school graduate
..40 to 44 years 1,611 Some college, no degree
..40 to 44 years 517 Associate's degree, occupational
..40 to 44 years 707 Associate's degree, academic
..40 to 44 years 2,440 Bachelor's degree
..40 to 44 years 1,185 Master's degree
..40 to 44 years 169 Professional degree
..40 to 44 years 197 Doctoral degree
..45 to 49 years 34 None
..45 to 49 years 50 1st - 4th grade
..45 to 49 years 173 5th - 6th grade
..45 to 49 years 151 7th - 8th grade
..45 to 49 years 160 9th grade
..45 to 49 years 174 10th grade
..45 to 49 years 281 11th grade /2
..45 to 49 years 2,762 High school graduate
..45 to 49 years 1,678 Some college, no degree
..45 to 49 years 486 Associate's degree, occupational
..45 to 49 years 783 Associate's degree, academic
..45 to 49 years 2,423 Bachelor's degree
..45 to 49 years 1005 Master's degree
..45 to 49 years 157 Professional degree
..45 to 49 years 149 Doctoral degree
..50 to 54 years 35 None
..50 to 54 years 95 1st - 4th grade
..50 to 54 years 151 5th - 6th grade
..50 to 54 years 157 7th - 8th grade
..50 to 54 years 147 9th grade
..50 to 54 years 182 10th grade
..50 to 54 years 322 11th grade /2
..50 to 54 years 3,322 High school graduate
..50 to 54 years 1,880 Some college, no degree
..50 to 54 years 562 Associate's degree, occupational
..50 to 54 years 829 Associate's degree, academic
..50 to 54 years 2,480 Bachelor's degree
..50 to 54 years 954 Master's degree
..50 to 54 years 131 Professional degree
..50 to 54 years 140 Doctoral degree
..55 to 59 years 25 None
..55 to 59 years 77 1st - 4th grade
..55 to 59 years 158 5th - 6th grade
..55 to 59 years 205 7th - 8th grade
..55 to 59 years 127 9th grade
..55 to 59 years 149 10th grade
..55 to 59 years 381 11th grade /2
..55 to 59 years 3,375 High school graduate
..55 to 59 years 1,909 Some college, no degree
..55 to 59 years 551 Associate's degree, occupational
..55 to 59 years 742 Associate's degree, academic
..55 to 59 years 2,062 Bachelor's degree
..55 to 59 years 1066 Master's degree
..55 to 59 years 130 Professional degree
..55 to 59 years 132 Doctoral degree
..60 to 64 years 32 None
..60 to 64 years 95 1st - 4th grade
..60 to 64 years 131 5th - 6th grade
..60 to 64 years 144 7th - 8th grade
..60 to 64 years 133 9th grade
..60 to 64 years 145 10th grade
..60 to 64 years 290 11th grade /2
..60 to 64 years 3,070 High school graduate
..60 to 64 years 1,687 Some college, no degree
..60 to 64 years 488 Associate's degree, occupational
..60 to 64 years 603 Associate's degree, academic
..60 to 64 years 1,750 Bachelor's degree
..60 to 64 years 1035 Master's degree
..60 to 64 years 140 Professional degree
..60 to 64 years 127 Doctoral degree
..65 to 69 years 55 None
..65 to 69 years 104 1st - 4th grade
..65 to 69 years 137 5th - 6th grade
..65 to 69 years 155 7th - 8th grade
..65 to 69 years 109 9th grade
..65 to 69 years 189 10th grade
..65 to 69 years 249 11th grade /2
..65 to 69 years 2,777 High school graduate
..65 to 69 years 1,405 Some college, no degree
..65 to 69 years 371 Associate's degree, occupational
..65 to 69 years 453 Associate's degree, academic
..65 to 69 years 1,347 Bachelor's degree
..65 to 69 years 772 Master's degree
..65 to 69 years 84 Professional degree
..65 to 69 years 129 Doctoral degree
..70 to 74 years 25 None
..70 to 74 years 69 1st - 4th grade
..70 to 74 years 114 5th - 6th grade
..70 to 74 years 153 7th - 8th grade
..70 to 74 years 116 9th grade
..70 to 74 years 200 10th grade
..70 to 74 years 252 11th grade /2
..70 to 74 years 2,238 High school graduate
..70 to 74 years 1,022 Some college, no degree
..70 to 74 years 227 Associate's degree, occupational
..70 to 74 years 250 Associate's degree, academic
..70 to 74 years 825 Bachelor's degree
..70 to 74 years 455 Master's degree
..70 to 74 years 36 Professional degree
..70 to 74 years 64 Doctoral degree
..75 years and over 122 None
..75 years and over 234 1st - 4th grade
..75 years and over 238 5th - 6th grade
..75 years and over 490 7th - 8th grade
..75 years and over 309 9th grade
..75 years and over 382 10th grade
..75 years and over 539 11th grade /2
..75 years and over 4,599 High school graduate
..75 years and over 1,544 Some college, no degree
..75 years and over 317 Associate's degree, occupational
..75 years and over 353 Associate's degree, academic
..75 years and over 1,314 Bachelor's degree
..75 years and over 570 Master's degree
..75 years and over 95 Professional degree
..75 years and over 67 Doctoral degree
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:10;right:10;bottom:0;left:0; }
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</style>
</head>
<body onLoad="toggleBetween()">
<FORM>
<INPUT type="button" value="Toggle" name="button" onClick="toggleBetween()">
</FORM>
<script>
var female=true;
var x = "level";
var y = "age";
var side = "number";
var w_plot = 700;
var h_plot = 250;
var margin = { left: 150, top: 5, right: 50, bottom: 200 };
var H = h_plot + margin.top + margin.bottom;
var W = w_plot + margin.left + margin.right;
var svg = d3.select("body").append("svg")
.attr("width", W)
.attr("height", H);
var plot_area = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var xScale = d3.scale.ordinal().rangeRoundPoints([0, w_plot]);
var yScale = d3.scale.ordinal().rangeRoundPoints([0, h_plot]);
var sizeScale = d3.scale.sqrt().domain([0, 6000]).range([1, 20]);
// Axes
var xAxisGroup = plot_area.append("g")
.attr("transform", "translate(0," + (h_plot+20) + ")")
.attr("class", "x axis");
var yAxisGroup = plot_area.append("g")
.attr("transform", "translate("+ (-5) +",0)")
.attr("class", "y axis");
var xAxis = d3.svg.axis().scale(xScale).orient("bottom");
var yAxis = d3.svg.axis().scale(yScale).orient("left");
function render(data, color){
xScale.domain(data.map( function (d){ return d[x]; }));
yScale.domain(data.map( function (d){ return d[y]; }));
xAxisGroup
.call(xAxis)
.selectAll("text")
.style("text-anchor", "start")
.attr("transform", "rotate(90),translate(4,-20)");
yAxisGroup.call(yAxis);
// Bind data
var squares = plot_area.selectAll("rect").data(data);
// Enter
squares.enter().append("rect")
.attr("opacity", 0.5);
// Update
squares
.attr("fill", color)
.attr("x", function (d){ return xScale(d[x]); })
.attr("y", function (d){ return yScale(d[y]); })
.attr("width", function(d){return sizeScale(d[side]); })
.attr("height", function(d){return sizeScale(d[side]); });
// Exit
squares.exit().remove();
}
function toNumbers(d){
d["number"] = +d["number"].replace(',','').replace('-','0');
return d;
}
function showMale(){
d3.csv("Male_flat.csv", toNumbers, function (objects){
render(objects, "blue");
});
}
function showFemale(){
d3.csv("Female_flat.csv", toNumbers, function (objects){
render(objects, "red");
});
}
function toggleBetween(){
if (female==true){
showMale();
female=false;
} else {
showFemale();
female=true;
}
}
</script>
</body>
age number level
..18 to 24 years 29 None
..18 to 24 years 39 1st - 4th grade
..18 to 24 years 63 5th - 6th grade
..18 to 24 years 116 7th - 8th grade
..18 to 24 years 159 9th grade
..18 to 24 years 334 10th grade
..18 to 24 years 1,943 11th grade /2
..18 to 24 years 5,011 High school graduate
..18 to 24 years 5,356 Some college, no degree
..18 to 24 years 319 Associate's degree, occupational
..18 to 24 years 393 Associate's degree, academic
..18 to 24 years 1,331 Bachelor's degree
..18 to 24 years 64 Master's degree
..18 to 24 years 5 Professional degree
..18 to 24 years 2 Doctoral degree
..25 to 29 years 23 None
..25 to 29 years 26 1st - 4th grade
..25 to 29 years 114 5th - 6th grade
..25 to 29 years 106 7th - 8th grade
..25 to 29 years 139 9th grade
..25 to 29 years 169 10th grade
..25 to 29 years 465 11th grade /2
..25 to 29 years 3,286 High school graduate
..25 to 29 years 2,122 Some college, no degree
..25 to 29 years 406 Associate's degree, occupational
..25 to 29 years 574 Associate's degree, academic
..25 to 29 years 2,783 Bachelor's degree
..25 to 29 years 599 Master's degree
..25 to 29 years 87 Professional degree
..25 to 29 years 85 Doctoral degree
..30 to 34 years 31 None
..30 to 34 years 86 1st - 4th grade
..30 to 34 years 142 5th - 6th grade
..30 to 34 years 127 7th - 8th grade
..30 to 34 years 207 9th grade
..30 to 34 years 173 10th grade
..30 to 34 years 432 11th grade /2
..30 to 34 years 2,911 High school graduate
..30 to 34 years 1,797 Some college, no degree
..30 to 34 years 445 Associate's degree, occupational
..30 to 34 years 576 Associate's degree, academic
..30 to 34 years 2,298 Bachelor's degree
..30 to 34 years 852 Master's degree
..30 to 34 years 203 Professional degree
..30 to 34 years 164 Doctoral degree
..35 to 39 years 52 None
..35 to 39 years 67 1st - 4th grade
..35 to 39 years 224 5th - 6th grade
..35 to 39 years 157 7th - 8th grade
..35 to 39 years 212 9th grade
..35 to 39 years 190 10th grade
..35 to 39 years 384 11th grade /2
..35 to 39 years 2,799 High school graduate
..35 to 39 years 1,597 Some college, no degree
..35 to 39 years 428 Associate's degree, occupational
..35 to 39 years 476 Associate's degree, academic
..35 to 39 years 2,071 Bachelor's degree
..35 to 39 years 839 Master's degree
..35 to 39 years 153 Professional degree
..35 to 39 years 181 Doctoral degree
..40 to 44 years 31 None
..40 to 44 years 85 1st - 4th grade
..40 to 44 years 198 5th - 6th grade
..40 to 44 years 172 7th - 8th grade
..40 to 44 years 163 9th grade
..40 to 44 years 158 10th grade
..40 to 44 years 315 11th grade /2
..40 to 44 years 2,867 High school graduate
..40 to 44 years 1,591 Some college, no degree
..40 to 44 years 410 Associate's degree, occupational
..40 to 44 years 490 Associate's degree, academic
..40 to 44 years 2,083 Bachelor's degree
..40 to 44 years 810 Master's degree
..40 to 44 years 214 Professional degree
..40 to 44 years 205 Doctoral degree
..45 to 49 years 45 None
..45 to 49 years 55 1st - 4th grade
..45 to 49 years 178 5th - 6th grade
..45 to 49 years 155 7th - 8th grade
..45 to 49 years 185 9th grade
..45 to 49 years 178 10th grade
..45 to 49 years 362 11th grade /2
..45 to 49 years 3,185 High school graduate
..45 to 49 years 1,485 Some college, no degree
..45 to 49 years 465 Associate's degree, occupational
..45 to 49 years 400 Associate's degree, academic
..45 to 49 years 2,077 Bachelor's degree
..45 to 49 years 977 Master's degree
..45 to 49 years 190 Professional degree
..45 to 49 years 160 Doctoral degree
..50 to 54 years 36 None
..50 to 54 years 98 1st - 4th grade
..50 to 54 years 171 5th - 6th grade
..50 to 54 years 160 7th - 8th grade
..50 to 54 years 178 9th grade
..50 to 54 years 219 10th grade
..50 to 54 years 444 11th grade /2
..50 to 54 years 3,550 High school graduate
..50 to 54 years 1,620 Some college, no degree
..50 to 54 years 491 Associate's degree, occupational
..50 to 54 years 544 Associate's degree, academic
..50 to 54 years 2,114 Bachelor's degree
..50 to 54 years 829 Master's degree
..50 to 54 years 178 Professional degree
..50 to 54 years 215 Doctoral degree
..55 to 59 years 33 None
..55 to 59 years 91 1st - 4th grade
..55 to 59 years 168 5th - 6th grade
..55 to 59 years 157 7th - 8th grade
..55 to 59 years 139 9th grade
..55 to 59 years 195 10th grade
..55 to 59 years 399 11th grade /2
..55 to 59 years 3,334 High school graduate
..55 to 59 years 1,704 Some college, no degree
..55 to 59 years 484 Associate's degree, occupational
..55 to 59 years 521 Associate's degree, academic
..55 to 59 years 1,886 Bachelor's degree
..55 to 59 years 775 Master's degree
..55 to 59 years 195 Professional degree
..55 to 59 years 248 Doctoral degree
..60 to 64 years 17 None
..60 to 64 years 80 1st - 4th grade
..60 to 64 years 143 5th - 6th grade
..60 to 64 years 149 7th - 8th grade
..60 to 64 years 113 9th grade
..60 to 64 years 155 10th grade
..60 to 64 years 274 11th grade /2
..60 to 64 years 2,762 High school graduate
..60 to 64 years 1,621 Some college, no degree
..60 to 64 years 376 Associate's degree, occupational
..60 to 64 years 493 Associate's degree, academic
..60 to 64 years 1,788 Bachelor's degree
..60 to 64 years 734 Master's degree
..60 to 64 years 220 Professional degree
..60 to 64 years 202 Doctoral degree
..65 to 69 years 37 None
..65 to 69 years 67 1st - 4th grade
..65 to 69 years 111 5th - 6th grade
..65 to 69 years 151 7th - 8th grade
..65 to 69 years 84 9th grade
..65 to 69 years 90 10th grade
..65 to 69 years 202 11th grade /2
..65 to 69 years 2,090 High school graduate
..65 to 69 years 1338 Some college, no degree
..65 to 69 years 289 Associate's degree, occupational
..65 to 69 years 338 Associate's degree, academic
..65 to 69 years 1455 Bachelor's degree
..65 to 69 years 704 Master's degree
..65 to 69 years 194 Professional degree
..65 to 69 years 242 Doctoral degree
..70 to 74 years 15 None
..70 to 74 years 68 1st - 4th grade
..70 to 74 years 106 5th - 6th grade
..70 to 74 years 148 7th - 8th grade
..70 to 74 years 86 9th grade
..70 to 74 years 155 10th grade
..70 to 74 years 160 11th grade /2
..70 to 74 years 1,591 High school graduate
..70 to 74 years 838 Some college, no degree
..70 to 74 years 163 Associate's degree, occupational
..70 to 74 years 202 Associate's degree, academic
..70 to 74 years 891 Bachelor's degree
..70 to 74 years 452 Master's degree
..70 to 74 years 138 Professional degree
..70 to 74 years 150 Doctoral degree
..75 years and over 56 None
..75 years and over 143 1st - 4th grade
..75 years and over 200 5th - 6th grade
..75 years and over 431 7th - 8th grade
..75 years and over 166 9th grade
..75 years and over 235 10th grade
..75 years and over 254 11th grade /2
..75 years and over 2,620 High school graduate
..75 years and over 1,060 Some college, no degree
..75 years and over 209 Associate's degree, occupational
..75 years and over 227 Associate's degree, academic
..75 years and over 1,251 Bachelor's degree
..75 years and over 585 Master's degree
..75 years and over 193 Professional degree
..75 years and over 253 Doctoral degree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment