This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.
-
-
Save jm3/42169e866b61eccfe633 to your computer and use it in GitHub Desktop.
Choropleth
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<style> | |
.counties { | |
fill: none; | |
} | |
.states { | |
fill: none; | |
stroke: #fff; | |
stroke-linejoin: round; | |
} | |
.q0-9 { fill:rgb(247,251,255); } | |
.q1-9 { fill:rgb(222,235,247); } | |
.q2-9 { fill:rgb(198,219,239); } | |
.q3-9 { fill:rgb(158,202,225); } | |
.q4-9 { fill:rgb(107,174,214); } | |
.q5-9 { fill:rgb(66,146,198); } | |
.q6-9 { fill:rgb(33,113,181); } | |
.q7-9 { fill:rgb(8,81,156); } | |
.q8-9 { fill:rgb(8,48,107); } | |
</style> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script> | |
<script> | |
var width = 960, | |
height = 600; | |
var rateById = d3.map(); | |
var quantize = d3.scale.quantize() | |
.domain([0, .15]) | |
.range(d3.range(9).map(function(i) { return "q" + i + "-9"; })); | |
var projection = d3.geo.albersUsa() | |
.scale(1280) | |
.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, "/mbostock/raw/4090846/us.json") | |
.defer(d3.tsv, "unemployment.tsv", function(d) { rateById.set(d.id, +d.rate); }) | |
.await(ready); | |
function ready(error, us) { | |
if (error) throw error; | |
svg.append("g") | |
.attr("class", "counties") | |
.selectAll("path") | |
.data(topojson.feature(us, us.objects.counties).features) | |
.enter().append("path") | |
.attr("class", function(d) { return quantize(rateById.get(d.id)); }) | |
.attr("d", path); | |
svg.append("path") | |
.datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; })) | |
.attr("class", "states") | |
.attr("d", path); | |
} | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> |
This file contains hidden or 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
State or territory | Population estimate forJuly 1, 2014 | Census population,April 1, 2010 | Census population,April 1, 2000 | 2014 Estimated pop.perHouse seat | 2010 Census pop.perHouseseat[4] | 2000 Census pop.perHouseseat | Percentof totalU.S. pop.,2014[5] | Comparable country | |
---|---|---|---|---|---|---|---|---|---|
California | 38,802,500 | 37,253,956 | 33,871,648 | 732,123 | 702,905 | 639,088 | 12.17% | Poland | |
Texas | 26,956,958 | 25,145,561 | 20,851,820 | 748,804 | 698,487 | 651,619 | 8.45% | Afghanistan | |
Florida | 19,893,297 | 18,801,310 | 15,982,378 | 736,789 | 696,345 | 639,295 | 6.24% | Romania | |
New York | 19,746,227 | 19,378,102 | 18,976,457 | 731,342 | 717,707 | 654,361 | 6.19% | Romania | |
Illinois | 12,880,580 | 12,830,632 | 12,419,293 | 715,588 | 712,813 | 653,647 | 4.04% | Zimbabwe | |
Pennsylvania | 12,787,209 | 12,702,379 | 12,281,054 | 710,401 | 705,688 | 646,371 | 4.01% | Zimbabwe | |
Ohio | 11,594,163 | 11,536,504 | 11,353,140 | 724,635 | 721,032 | 630,730 | 3.64% | Tunisia | |
Georgia | 10,097,343 | 9,687,653 | 8,186,453 | 721,239 | 691,975 | 629,727 | 3.17% | Benin | |
North Carolina | 9,943,964 | 9,535,483 | 8,049,313 | 764,920 | 733,498 | 619,178 | 3.12% | Hungary | |
Michigan | 9,909,877 | 9,883,640 | 9,938,444 | 707,848 | 705,974 | 662,563 | 3.11% | Hungary | |
New Jersey | 8,938,175 | 8,791,894 | 8,414,350 | 744,848 | 732,658 | 647,258 | 2.80% | Honduras | |
Virginia | 8,326,289 | 8,001,024 | 7,078,515 | 756,935 | 727,366 | 643,501 | 2.61% | Tajikistan | |
Washington | 7,061,530 | 6,724,540 | 5,894,121 | 706,153 | 672,454 | 654,902 | 2.21% | Paraguay | |
Massachusetts | 6,745,408 | 6,547,629 | 6,349,097 | 749,490 | 727,514 | 634,910 | 2.12% | Jordan | |
Arizona | 6,731,484 | 6,392,017 | 5,130,632 | 747,943 | 710,224 | 641,329 | 2.11% | Eritrea | |
Indiana | 6,596,855 | 6,483,802 | 6,080,485 | 732,984 | 720,422 | 675,609 | 2.07% | El Salvador | |
Tennessee | 6,549,352 | 6,346,105 | 5,689,283 | 727,706 | 705,123 | 632,143 | 2.05% | El Salvador | |
Missouri | 6,063,589 | 5,988,927 | 5,595,211 | 757,949 | 748,615 | 621,690 | 1.90% | Nicaragua | |
Maryland | 5,976,407 | 5,773,552 | 5,296,486 | 747,051 | 721,694 | 662,061 | 1.87% | Kyrgyzstan | |
Wisconsin | 5,757,564 | 5,686,986 | 5,363,675 | 719,696 | 710,873 | 670,459 | 1.81% | Denmark | |
Minnesota | 5,457,173 | 5,303,925 | 4,919,479 | 682,147 | 662,991 | 614,935 | 1.71% | Singapore | |
Colorado | 5,355,866 | 5,029,196 | 4,301,261 | 765,124 | 720,704 | 614,466 | 1.68% | Slovakia | |
Alabama | 4,849,377 | 4,779,736 | 4,447,100 | 692,768 | 682,819 | 635,300 | 1.52% | Central African Republic | |
South Carolina | 4,832,482 | 4,625,364 | 4,012,012 | 690,355 | 660,766 | 668,669 | 1.52% | Central African Republic | |
Louisiana | 4,649,676 | 4,533,372 | 4,468,976 | 774,946 | 755,562 | 638,425 | 1.46% | Republic of the Congo | |
Kentucky | 4,413,457 | 4,339,367 | 4,041,769 | 735,576 | 723,228 | 673,628 | 1.38% | New Zealand | |
Oregon | 3,970,239 | 3,831,074 | 3,421,399 | 794,048 | 766,215 | 684,280 | 1.25% | Lebanon | |
Oklahoma | 3,878,051 | 3,751,351 | 3,450,654 | 775,610 | 750,270 | 690,131 | 1.22% | Bosnia | |
Puerto Rico | 3,548,397 | 3,725,789 | 3,808,610 | — | — | — | 1.11% | Moldova | |
Connecticut | 3,596,677 | 3,574,097 | 3,405,565 | 719,335 | 714,819 | 681,113 | 1.13% | Moldova | |
Iowa | 3,107,126 | 3,046,355 | 2,926,324 | 776,782 | 761,589 | 585,265 | 0.97% | Mongolia | |
Mississippi | 2,994,079 | 2,967,297 | 2,844,658 | 748,520 | 741,824 | 711,165 | 0.94% | Armenia | |
Arkansas | 2,966,369 | 2,915,918 | 2,673,400 | 741,592 | 728,980 | 668,350 | 0.93% | Armenia | |
Utah | 2,942,902 | 2,763,885 | 2,233,169 | 735,726 | 690,221 | 744,390 | 0.92% | Lithuania | |
Kansas | 2,904,021 | 2,853,118 | 2,688,418 | 726,005 | 713,280 | 672,105 | 0.91% | Lithuania | |
Nevada | 2,839,098 | 2,700,551 | 1,998,257 | 709,775 | 675,110 | 666,086 | 0.89% | Albania | |
New Mexico | 2,085,572 | 2,059,179 | 1,819,046 | 695,191 | 686,393 | 606,349 | 0.65% | Slovenia | |
Nebraska | 1,881,503 | 1,826,341 | 1,711,263 | 627,168 | 608,780 | 570,421 | 0.59% | Gambia | |
West Virginia | 1,850,326 | 1,852,994 | 1,808,344 | 616,775 | 617,665 | 602,781 | 0.58% | Kosovo | |
Idaho | 1,634,464 | 1,567,582 | 1,293,953 | 817,232 | 783,791 | 646,977 | 0.51% | Gabon | |
Hawaii | 1,419,561 | 1,360,301 | 1,211,537 | 709,781 | 680,151 | 605,769 | 0.45% | Equatorial Guinea | |
Maine | 1,330,089 | 1,328,361 | 1,274,923 | 665,045 | 664,181 | 637,462 | 0.42% | Trinidad and Tobago | |
New Hampshire | 1,326,813 | 1,316,470 | 1,235,786 | 663,407 | 658,235 | 617,893 | 0.42% | Trinidad and Tobago | |
Rhode Island | 1,055,173 | 1,052,567 | 1,048,319 | 527,587 | 526,284 | 524,160 | 0.33% | Swaziland | |
Montana | 1,023,579 | 989,415 | 902,195 | 1,023,579 | 989,415 | 902,195 | 0.32% | Djibouti | |
Delaware | 935,614 | 897,934 | 783,600 | 935,614 | 897,934 | 783,600 | 0.29% | Djibouti | |
South Dakota | 853,175 | 814,180 | 754,844 | 853,175 | 814,180 | 754,844 | 0.27% | Fiji | |
North Dakota | 739,482 | 672,591 | 642,200 | 739,482 | 672,591 | 642,200 | 0.23% | Guyana | |
Alaska | 736,732 | 710,231 | 626,932 | 736,732 | 710,231 | 626,932 | 0.23% | Guyana | |
District of Columbia | 658,893 | 601,723 | 572,059 | — | — | — | 0.21% | Montenegro | |
Vermont | 626,562 | 625,741 | 608,827 | 626,562 | 625,741 | 608,827 | 0.20% | Montenegro | |
Wyoming | 584,153 | 563,626 | 493,782 | 584,153 | 563,626 | 493,782 | 0.18% | Solomon Islands | |
Guam | — | 159,358[7] | 154,805 | — | — | — | 0.06% | Saint Lucia | |
U.S. Virgin Islands | — | 106,405[8] | 108,612 | — | — | — | 0.04% | Kiribati | |
American Samoa | — | 55,519[9] | 57,291 | — | — | — | 0.02% | Saint Kitts and Nevis | |
Northern Mariana Islands | — | 53,883[10] | 69,221 | — | — | — | 0.02% | Saint Kitts and Nevis | |
The fifty states | 318,198,163 | 308,143,815 | 280,849,847 | 725,249 | 708,376 | 645,632 | 98.48% | ||
Fifty states + D.C. | 318,857,056 | 308,745,538 | 281,421,906 | — | — | — | 98.67% | — | |
Total U.S. territory | — | 312,913,872 | 285,620,445 | — | — | — | 100 | — |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment