Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Last active January 30, 2017 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradoyler/85ad923835da270ddb27207de6f99cc0 to your computer and use it in GitHub Desktop.
Save bradoyler/85ad923835da270ddb27207de6f99cc0 to your computer and use it in GitHub Desktop.
crime rate (us cities) scatterplot
license: mit
city pop_2015 violent_crime murder murder_rate
Newark 281944 0 105 37.24
Portland 632309 0 34 5.3
Chicago 2728695 24663 478 17.51753127
New York 8550861 50088 352 4.116544521
Baltimore 621252 9542 344 55.37205514
Houston 2275221 21994 303 13.31738763
Detroit 673225 11846 295 43.81893126
Los Angeles 3962726 25156 282 7.116313366
Philadelphia 1567810 16132 280 17.85930693
St. Louis 317095 5762 188 59.28822593
New Orleans 393447 3736 164 41.68286961
Washington 672228 8084 162 24.09896642
Indianapolis 863675 11124 148 17.13607549
Milwaukee 600400 9583 145 24.15056629
Dallas 1301977 9038 136 10.44565303
Memphis 657936 11449 135 20.51871307
Las Vegas 1562134 14383 127 8.129904349
Phoenix 1559744 9261 112 7.180665545
Kansas City 473373 6709 109 23.02623935
Jacksonville 867258 5622 97 11.1846763
Atlanta 464710 5203 94 20.22766887
San Antonio 1463586 8594 94 6.422581249
Oakland 419481 6051 85 20.26313468
Louisville 680550 4300 81 11.90213798
Columbus 847745 4631 77 9.082919982
Miami 437969 4473 75 17.12449968
Oklahoma City 630621 4828 73 11.57589107
Nashville 658029 7245 72 10.941767
Cincinnati 298478 2761 66 22.11218247
Charlotte 877817 5948 61 6.94905658
Pittsburgh 306870 2167 57 18.57464073
Fort Worth 829731 4359 56 6.749175335
Tulsa 401520 3628 55 13.6979478
Denver 682418 4599 53 7.766500884
San Francisco 863782 6710 53 6.135807414
Stockton 304890 4122 49 16.07137
Omaha 452252 2329 48 10.61355174
Minneapolis 413479 4395 47 11.3669618
Albuquerque 559721 5406 43 7.682398909
Sacramento 489717 3611 43 8.780581438
Buffalo 258096 2887 41 15.88556196
Fresno 520837 2871 39 7.487947285
Boston 665258 4702 38 5.712069603
San Diego 1400467 5582 37 2.641975855
Long Beach 476318 2766 36 7.557975974
Durham 257911 2185 34 13.18284214
Tampa 364383 2298 34 9.33084145
Orlando 268438 2525 32 11.92081598
Tucson 529675 3472 31 5.85264549
San Jose 1031458 3400 30 2.908504273
Jersey City 265159 1383 27 10.1825697
Wichita 389824 3839 27 6.926202594
Anchorage 301239 3226 26 8.631020552
Greensboro 285950 1707 26 9.092498689
Colorado Springs 452410 1983 25 5.525960965
Fort Wayne 259712 984 25 9.626047314
Aurora 360237 1660 24 6.662280665
Mobile 250346 1529 24 9.586731963
Toledo 279552 3156 24 8.585164835
Austin 938728 3497 23 2.450123998
Seattle 683700 4093 23 3.364048559
Bakersfield 373887 1810 22 5.884130767
Virginia Beach 452797 626 19 4.196140875
Anaheim 349471 1271 18 5.15064197
Corpus Christi 324326 2092 17 5.241639585
El Paso 686077 2515 17 2.477855984
Mesa 471034 1972 16 3.396782398
St. Paul 300721 2115 16 5.320546287
Honolulu 999307 2437 15 1.501040221
Lexington 314077 1044 15 4.775898904
St. Petersburg 255821 1898 14 5.472576528
Santa Ana 337304 1626 12 3.557621611
Riverside 323064 1441 10 3.09536191
Arlington 387565 1946 8 2.064169881
Laredo 256280 972 8 3.121585766
Chula Vista 265215 705 6 2.26231548
Henderson 282554 476 4 1.4156586
Plano 282968 433 4 1.413587402
Irvine 258198 144 2 0.7745993385
Chandler 258875 490 1 0.386286818
Lincoln 276585 1025 1 0.3615525065
<!doctype html>
<head>
<meta charset="utf-8">
<head>
<body>
<div id="viz"></div>
<script src="//d3plus.org/js/d3.js"></script>
<script src="//d3plus.org/js/d3plus.js"></script>
<script>
function type(d) {
var row = {
murders: +d.murder,
'murder rate per 100k': +d.murder_rate,
city: d.city,
'2015 Population': +d.pop_2015
};
return row;
}
d3.csv("crime-in-us-2015.csv", type, function(error, data) {
if (error) {
throw error;
}
var visualization = d3plus.viz()
.container('#viz') // container DIV to hold the visualization
.data(data) // data to use with the visualization
.type('scatter') // visualization type
.id('city') // key for which our data is unique on
.x('2015 Population') // key for x-axis
.y('murders') // key for y-axis
.size('murder rate per 100k')
.draw()
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment