Skip to content

Instantly share code, notes, and snippets.

@danasilver
Created March 13, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danasilver/9536993 to your computer and use it in GitHub Desktop.
Save danasilver/9536993 to your computer and use it in GitHub Desktop.
U.S. Income Choropleth

A choropleth of the average per capita income by state according to the 2010 U.S. census. Hover over a state for more information.

Abbr State population perUnder5 perUnder18 perOver65 perF perWhite perBlack perNative perAsian perPacific perMix perSameHouse perForeignBorn perHighSchool perCollege veterans travelTime income incomeHousehold perPoverty squareMiles popPerSqMile
AL ALABAMA 4779736 6.3 23.3 14.5 51.5 70 26.5 0.7 1.2 0.1 1.5 84.9 3.5 82.6 22.3 398343 24.1 23587 43160 18.1 50645.33 94.4
AK ALASKA 710231 7.5 25.6 8.5 47.9 67.5 3.7 14.8 5.7 1.2 7.1 79.7 6.9 91.6 27.5 72090 18.6 32537 69917 9.6 570640.95 1.2
AZ ARIZONA 6392017 6.7 24.7 14.8 50.3 84.3 4.5 5.3 3.1 0.3 2.5 80.4 13.6 85.4 26.6 530693 24.6 25571 50256 17.2 113594.08 56.3
AR ARKANSAS 2915918 6.6 24.1 15 50.9 80 15.6 0.9 1.4 0.3 1.8 83 4.4 83.3 19.8 242151 21.3 22007 40531 18.7 52035.48 56
CA CALIFORNIA 37253956 6.7 24.3 12.1 50.3 73.7 6.6 1.7 13.9 0.5 3.6 84.2 27.1 81 30.5 1952910 27.1 29551 61400 15.3 155779.22 239.1
CO COLORADO 5029196 6.5 23.7 11.8 49.8 88.1 4.3 1.6 3 0.2 2.8 80.8 9.7 89.9 36.7 405895 24.4 31039 58244 12.9 103641.89 48.5
CT CONNECTICUT 3574097 5.4 22.1 14.8 51.3 82 11.2 0.5 4.2 0.1 2.1 87.9 13.5 89 36.2 228291 24.8 37807 69519 10 4842.36 738.1
DE DELAWARE 897934 6.1 22.4 15.3 51.5 71.4 22 0.7 3.5 0.1 2.4 85.8 8.3 87.7 28.5 76752 24.8 29733 60119 11.5 1948.54 460.8
DISTRICT OF COLUMBIA 601723 6.1 17.3 11.4 52.7 42.9 50.1 0.6 3.8 0.2 2.5 80.3 13.5 87.5 51.2 30777 29.6 45004 64267 18.5 61.05 9856.5
FL FLORIDA 18801310 5.5 20.7 18.2 51.1 78.3 16.6 0.5 2.7 0.1 1.9 83.7 19.3 85.8 26.2 1606758 25.8 26451 47309 15.6 53624.76 350.6
GA GEORGIA 9687653 6.8 25.1 11.5 51.1 62.8 31.2 0.5 3.5 0.1 1.8 83.3 9.7 84.4 27.8 701808 27 25309 49604 17.4 57513.49 168.4
HI HAWAII 1360301 6.4 21.8 15.1 49.6 26.1 2.1 0.4 38.3 10.1 23 84.9 18.1 90.3 29.6 112589 25.8 29227 67492 10.8 6422.63 211.8
ID IDAHO 1567582 7.3 26.7 13.3 50 93.8 0.8 1.7 1.4 0.2 2.2 82.3 6 88.6 24.7 125905 20.1 22581 47015 15.1 82643.12 19
IL ILLINOIS 12830632 6.3 23.8 13.2 50.9 77.9 14.8 0.6 5 0.1 1.7 86.8 13.8 87 31.1 755256 28.1 29519 56853 13.7 55518.93 231.1
IN INDIANA 6483802 6.5 24.3 13.6 50.8 86.6 9.4 0.4 1.8 0.1 1.8 84.7 4.6 87 23 468648 23.2 24558 48374 14.7 35826.11 181
IA IOWA 3046355 6.4 23.5 15.3 50.4 92.8 3.2 0.5 2 0.1 1.6 84.7 4.3 90.7 25.3 233698 18.7 26545 51129 12.2 55857.13 54.5
KS KANSAS 2853118 7 25.1 13.7 50.3 87.2 6.2 1.2 2.6 0.1 2.7 83 6.5 89.7 30 218511 18.9 26845 51273 13.2 81758.72 34.9
KY KENTUCKY 4339367 6.4 23.2 14 50.7 88.6 8.1 0.3 1.3 0.1 1.6 84.9 3.2 82.4 21 319678 22.7 23210 42610 18.6 39486.34 109.9
LA LOUISIANA 4533372 6.8 24.3 12.9 51.1 63.7 32.4 0.7 1.7 0.1 1.4 85.5 3.7 82.2 21.4 313006 24.9 24264 44673 18.7 43203.9 104.9
ME MAINE 1328361 5 20 17 51.1 95.3 1.3 0.7 1.1 0 1.5 86.3 3.3 90.6 27.3 130685 23.3 26464 48219 13.3 30842.92 43.1
MD MARYLAND 5773552 6.2 22.8 13 51.6 60.8 30 0.5 6 0.1 2.5 86.6 13.8 88.5 36.3 438387 31.8 36056 72999 9.4 9707.24 594.8
MA MASSACHUSETTS 6547629 5.5 21.1 14.4 51.5 83.7 7.9 0.5 5.8 0.1 2 86.7 14.8 89.1 39 400874 27.7 35485 66658 11 7800.06 839.4
MI MICHIGAN 9883640 5.8 22.9 14.6 50.9 80.1 14.3 0.7 2.6 0 2.2 85.4 6 88.7 25.5 692582 23.9 25547 48471 16.3 56538.9 174.8
MN MINNESOTA 5303925 6.5 23.7 13.6 50.3 86.5 5.5 1.3 4.4 0.1 2.2 85.5 7.2 91.9 32.2 377522 22.7 30656 59126 11.2 79626.74 66.6
MS MISSISSIPPI 2967297 6.8 25 13.5 51.4 59.9 37.4 0.6 0.9 0.1 1.1 85.6 2.2 81 20 207673 23.9 20670 38882 22.3 46923.27 63.2
MO MISSOURI 5988927 6.3 23.3 14.7 51 83.9 11.7 0.5 1.8 0.1 2 83.6 3.9 87.2 25.8 494876 23.2 25546 47333 15 68741.52 87.1
MT MONTANA 989415 6.1 22.1 15.7 49.8 89.7 0.6 6.5 0.7 0.1 2.5 83.6 2 91.9 28.5 97991 18 25002 45456 14.8 145545.8 6.8
NE NEBRASKA 1826341 7.1 25 13.9 50.3 89.9 4.8 1.3 2 0.1 1.9 83.2 6.2 90.4 28.1 146852 18.1 26523 51381 12.4 76824.17 23.8
NV NEVADA 2700551 6.6 24.1 13.1 49.6 77.1 8.9 1.6 7.9 0.7 3.8 77.7 19.2 84.4 22.2 229570 23.8 27003 54083 14.2 109781.18 24.6
NH NEW HAMPSHIRE 1316470 5 20.8 14.7 50.6 94.4 1.4 0.3 2.4 0 1.5 86.7 5.3 91.4 33.4 115415 26.2 32758 64925 8.4 8952.65 147
NJ NEW JERSEY 8791894 6 22.9 14.1 51.2 73.8 14.7 0.6 9 0.1 1.9 90 20.8 87.9 35.4 457724 30.3 35928 71637 9.9 7354.22 1195.5
NM NEW MEXICO 2059179 6.9 24.7 14.1 50.5 83.2 2.4 10.2 1.6 0.2 2.4 84.8 9.8 83.4 25.6 175832 21.7 23749 44886 19.5 121298.15 17
NY NEW YORK 19378102 6 21.8 14.1 51.5 71.2 17.5 1 8 0.1 2.2 88.7 22 84.9 32.8 957004 31.5 32104 57683 14.9 47126.4 411.2
NC NORTH CAROLINA 9535483 6.4 23.4 13.8 51.3 71.9 22 1.5 2.5 0.1 2 84.4 7.5 84.5 26.8 738926 23.5 25285 46450 16.8 48617.91 196.1
ND NORTH DAKOTA 672591 6.6 22.1 14.4 49.2 90.1 1.5 5.5 1.1 0.1 1.8 82.9 2.5 90.5 27.1 54782 16.5 28700 51641 12.1 69000.8 9.7
OH OHIO 11536504 6 23.1 14.8 51.1 83.4 12.5 0.3 1.8 0 2 85.4 3.9 88.2 24.7 893168 23 25857 48246 15.4 40860.69 282.3
OK OKLAHOMA 3751351 6.9 24.6 14 50.5 75.5 7.6 9 1.9 0.2 5.8 82.1 5.5 86.2 23.2 322008 21 24046 44891 16.6 68594.92 54.7
OR OREGON 3831074 6 22.1 14.9 50.5 88.3 2 1.8 4 0.4 3.5 82.1 9.8 89.2 29.2 333395 22.4 26702 50036 15.5 95988.01 39.9
PA PENNSYLVANIA 12702379 5.6 21.5 16 51.2 83.5 11.4 0.3 3 0.1 1.7 87.8 5.8 88.3 27 981865 25.8 28190 52267 13.1 44742.7 283.9
RI RHODE ISLAND 1052567 5.2 20.6 15.1 51.6 85.9 7.3 0.9 3.2 0.2 2.5 86.3 13 84.8 30.8 74982 23.4 30005 56102 13.2 1033.81 1018.1
SC SOUTH CAROLINA 4625364 6.3 22.9 14.7 51.4 68.4 28 0.5 1.4 0.1 1.6 84.7 4.8 84 24.6 396873 23.4 23906 44623 17.6 30060.7 153.9
SD SOUTH DAKOTA 814180 7.1 24.5 14.7 49.8 86.2 1.7 8.9 1.1 0.1 2.1 83.9 2.6 90.1 26 69787 16.8 25570 49091 13.8 75811 10.7
TN TENNESSEE 6346105 6.3 23.1 14.2 51.2 79.3 17 0.4 1.6 0.1 1.6 84.4 4.5 83.9 23.5 493980 24.1 24294 44140 17.3 41234.9 153.9
TX TEXAS 25145561 7.5 26.8 10.9 50.3 80.6 12.3 1 4.2 0.1 1.7 82.6 16.3 80.8 26.3 1611660 24.9 25809 51563 17.4 261231.71 96.3
UT UTAH 2763885 9 31.1 9.5 49.7 91.8 1.3 1.5 2.2 1 2.3 82.6 8.3 90.6 29.9 146524 21.5 23794 58164 12.1 82169.62 33.6
VT VERMONT 625741 4.9 19.8 15.7 50.7 95.4 1.1 0.4 1.4 0 1.7 86.3 4 91.3 34.2 50705 22.1 28846 54168 11.6 9216.66 67.9
VA VIRGINIA 8001024 6.2 22.7 13 50.9 71.1 19.7 0.5 6 0.1 2.6 84.7 11.1 86.9 34.7 734151 27.5 33326 63636 11.1 39490.09 202.6
WA WASHINGTON 6724540 6.4 23 13.2 50.1 81.6 3.9 1.8 7.7 0.7 4.3 82.6 13 90 31.6 594914 25.5 30661 59374 12.9 66455.52 101.2
WV WEST VIRGINIA 1852994 5.6 20.7 16.8 50.7 94 3.5 0.2 0.7 0 1.5 87.9 1.4 83.4 17.9 164979 25.4 22482 40400 17.6 24038.21 77.1
WI WISCONSIN 5686986 6.1 23 14.4 50.4 88.2 6.5 1.1 2.5 0 1.7 85.8 4.6 90.2 26.4 423264 21.6 27426 52627 12.5 54157.8 105
WY WYOMING 563626 6.7 23.5 13.1 48.9 93.1 1.5 2.6 0.9 0.1 1.8 81.8 3.2 92.1 24.3 51203 18.5 28858 56573 11 97093.14 5.8
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 14px sans-serif;
}
.states {
fill: none;
stroke: #fff;
stroke-linejoin: round;
}
.Oranges .q0-9{fill:rgb(255,245,235)}
.Oranges .q1-9{fill:rgb(254,230,206)}
.Oranges .q2-9{fill:rgb(253,208,162)}
.Oranges .q3-9{fill:rgb(253,174,107)}
.Oranges .q4-9{fill:rgb(253,141,60)}
.Oranges .q5-9{fill:rgb(241,105,19)}
.Oranges .q6-9{fill:rgb(217,72,1)}
.Oranges .q7-9{fill:rgb(166,54,3)}
.Oranges .q8-9{fill:rgb(127,39,4)}
.focus text {
fill: black;
font-weight: 600;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500;
var popById = d3.map();
var quantize = d3.scale.quantize()
.range(d3.range(9).map(function(i) { return "q" + i + "-9"; }));
var projection = d3.geo.albersUsa()
.scale(1000)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
queue()
.defer(d3.json, "/danasilver/raw/9497067/us2.json")
.defer(d3.csv, "census.csv", function(d) { popById.set(d.Abbr, +d.income); })
.await(plot);
function plot(error, us) {
quantize.domain(d3.extent(popById.values()));
svg.append("g")
.attr("class", "states Oranges")
.selectAll("path")
.data(topojson.feature(us, us.objects.usStates).features)
.enter().append("path")
.attr("class", function(d) { return quantize(popById.get(d.properties.STATE_ABBR)); })
.attr("d", path)
.on("mouseover", function() { focus.style("display", null); })
.on("mouseout", function() { focus.style("display", "none"); })
.on("mousemove", function(d) {
var pos = d3.mouse(this);
focus.select(".abbr").text(d.properties.STATE_ABBR);
focus.select(".income").text("Income: $" + popById.get(d.properties.STATE_ABBR));
focus.attr("transform", "translate(" + pos[0] + "," + pos[1] + ")");
});
var focus = svg.append("g")
.attr("class", "focus")
.style("display", "none");
focus.append("text")
.attr("class", "abbr")
.attr("x", -10)
.attr("y", -30)
.attr("dy", ".35em");
focus.append("text")
.attr("class", "income")
.attr("x", -10)
.attr("y", -13)
.attr("dy", ".35em");
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment