Skip to content

Instantly share code, notes, and snippets.

@sdawson
Created May 22, 2013 08:39
Show Gist options
  • Save sdawson/5626131 to your computer and use it in GitHub Desktop.
Save sdawson/5626131 to your computer and use it in GitHub Desktop.
antsim_pdf2
NoOfDeaths MinBlueDeath MajBlueDeath MinRedDeath MajRedDeath
13 0 0 0 2
14 0 0 0 1
15 0 0 0 2
16 0 3 0 0
17 0 5 0 10
18 0 6 0 8
19 0 15 0 5
20 0 25 0 20
21 0 30 0 23
22 0 36 0 41
23 0 39 0 45
24 0 66 0 78
25 0 74 0 81
26 0 128 0 107
27 0 137 0 126
28 0 140 0 155
29 0 192 0 172
30 0 186 0 191
31 0 206 0 225
32 0 224 0 245
33 0 248 0 223
34 0 232 0 230
35 0 220 0 215
36 0 228 0 225
37 0 252 0 236
38 0 208 0 202
39 0 181 0 189
40 0 150 0 171
41 0 125 0 153
42 0 133 0 111
43 0 83 0 115
44 0 97 0 64
45 0 95 0 89
46 0 65 0 54
47 0 43 0 38
48 0 29 0 38
49 0 27 0 24
50 1 16 0 14
51 0 15 0 19
52 0 14 0 13
53 0 8 0 14
54 0 6 0 7
55 0 4 0 6
56 0 1 0 3
57 0 1 0 3
58 0 4 0 2
59 0 0 0 2
60 1 1 0 0
61 0 0 0 1
62 1 0 1 0
63 0 1 0 0
64 0 0 1 0
65 2 0 0 1
66 4 0 1 0
67 5 0 2 0
68 3 0 6 0
69 5 0 1 0
70 6 0 5 0
71 5 0 2 0
72 12 0 8 0
73 9 0 7 0
74 18 0 16 0
75 19 0 9 0
76 19 0 18 0
77 24 0 40 0
78 25 0 35 0
79 38 0 51 0
80 56 0 42 0
81 45 0 49 0
82 62 0 56 0
83 75 0 63 0
84 72 0 83 0
85 92 0 98 0
86 91 0 94 0
87 114 0 101 0
88 96 0 112 0
89 112 0 126 0
90 138 0 132 0
91 137 0 132 0
92 135 0 130 0
93 143 0 146 0
94 125 0 163 0
95 137 0 165 0
96 149 0 161 0
97 144 0 141 0
98 147 0 145 0
99 158 0 134 0
100 147 0 141 0
101 132 0 142 0
102 134 0 130 0
103 121 0 125 0
104 109 0 122 0
105 105 0 112 0
106 97 0 91 0
107 86 0 112 0
108 95 0 59 0
109 61 0 75 0
110 76 0 65 0
111 62 0 50 0
112 49 0 40 0
113 52 0 31 0
114 35 0 33 0
115 39 0 33 0
116 24 0 30 0
117 28 0 23 0
118 20 0 15 0
119 17 0 12 0
120 13 0 11 0
121 17 0 11 0
122 8 0 12 0
123 7 0 14 0
124 11 0 4 0
125 5 0 10 0
126 4 0 4 0
127 6 0 3 0
128 4 0 3 0
129 1 0 2 0
130 2 0 1 0
131 2 0 1 0
132 4 0 2 0
133 1 0 0 0
134 0 0 2 0
135 0 0 2 0
NoOfDeaths MinBlueDeath MajBlueDeath MinRedDeath MajRedDeath
20 0 25 0 20
21 0 30 0 23
22 0 36 0 41
23 0 39 0 45
24 0 66 0 78
25 0 74 0 81
{"description":"antsim_pdf2","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"antsim_v1.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"antsim_v2.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
var short_data = tributary.antsim_v1;
short_data.forEach(function(d) {
d.noOfDeaths = +d.NoOfDeaths;
d.minBlueDeath = +d.MinBlueDeath;
d.majBlueDeath = +d.MajBlueDeath;
d.minRedDeath = +d.MinRedDeath;
d.majRedDeath = +d.MajRedDeath;
});
//console.log(short_data);
var svg = d3.select("svg");
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 950 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var colour = d3.scale.category10();
svg.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var x_axis = d3.svg.axis()
.scale(x)
.orient("bottom");
var y_axis = d3.svg.axis()
.scale(y)
.orient("left");
var line1 = d3.svg.line()
.x(function(d) {
return x(d.noOfDeaths); })
.y(function(d) {
return y(d.majBlueDeath); })
.interpolate("monotone");
var line2 = d3.svg.line()
.x(function(d) {
return x(d.noOfDeaths); })
.y(function(d) {
return y(d.minBlueDeath); })
.interpolate("monotone");
var line3 = d3.svg.line()
.x(function(d) {
return x(d.noOfDeaths); })
.y(function(d) {
return y(d.majRedDeath); })
.interpolate("monotone");
var line4 = d3.svg.line()
.x(function(d) {
return x(d.noOfDeaths); })
.y(function(d) {
return y(d.minRedDeath); })
.interpolate("monotone");
test_group = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
x.domain(d3.extent(short_data, function(d) { return d.noOfDeaths; }));
y.domain(d3.extent(short_data, function(d) { return d.majBlueDeath; }));
test_group.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (height + 0) + ")")
.call(x_axis);
test_group.append("g")
.attr("class", "y axis")
.call(y_axis);
test_group.append("path")
.datum(short_data)
.attr("class", "line1")
.attr("d", line1);
test_group.append("path")
.datum(short_data)
.attr("class", "line2")
.attr("d", line2);
test_group.append("path")
.datum(short_data)
.attr("class", "line3")
.attr("d", line3);
test_group.append("path")
.datum(short_data)
.attr("class", "line4")
.attr("d", line4);
.line1 {
fill: none;
stroke: #451495;
stroke-width: 1.5px;
}
.line2 {
fill: none;
stroke: #BFC52A;
stroke-width: 1.5px;
}
.line3 {
fill: none;
stroke: #B80505;
stroke-width: 1.5px;
}
.line4 {
fill: none;
stroke: #4AA81E;
stroke-width: 1.5px;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
body {
font: 11px sans-serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment