-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyour-commute-is-getting-worse.html
333 lines (285 loc) · 14.7 KB
/
your-commute-is-getting-worse.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
---
layout: default
custom_css: wmata-delay
---
<script src="https://d3js.org/d3.v3.min.js"></script>
<h2><a href='./your-commute-is-getting-worse.html'>The Pain is Real: Your Metro Commute is Getting Worse</a></h2>
<hr id='top-line'>
<h3> Kate Rabinowitz // August 9, 2015</h3>
<p class='content'>Last Thursday Metro sent a subtle signal that maybe I should <a class='link' target="_blank" href='http://www.washingtonpost.com/blogs/dr-gridlock/wp/2015/08/06/derailment-of-non-passenger-metro-train-delays-on-blue-orange-and-silver-lines/'>take a day off.</a> Unfortunately my boss felt otherwise. What started as a 'minor' derailment became two days of Metro competing with walking for the slowest way to get anywhere. It was bad and feels like part of a larger decline in Metro service. I was curious if that actually bore out in the data. Not only did it, but the decline is even more dramatic than I would've guessed.</p>
<p class='graph-title'>Metro Delays for the First Half of 2013-15</p>
<p class='graph-subtitle'> Number of delays reported on Metro for the first half of 2013, 2014 and 2015</p>
<div id="barchart1">
<svg class="chart"></svg>
<script>
(function() {
var margin = {top: 20, right: 0, bottom: 17, left: 35},
width = 400 - margin.left - margin.right,
height = 300- margin.top - margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .2);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.outerTickSize(0)
.orient("left");
var chart = d3.select(".chart")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.csv("https://raw.githubusercontent.com/katerabinowitz/Wmata-Delay/master/H1-Delays.csv", type, function(error, data) {
x.domain(data.map(function(d) { return d.H1; }));
y.domain([0, d3.max(data, function(d) { return d.DelayCountH1; })]);
chart.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
chart.append("g")
.attr("class", "y axis")
.call(yAxis);
chart.selectAll(".bar")
.data(data)
.enter()
.append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.H1); })
.attr("y", function(d) { return y(d.DelayCountH1); })
.attr("height", function(d) { return height - y(d.DelayCountH1); })
.attr("width", x.rangeBand());
});
function type(d) {
d.value = +d.value;
return d;
}
})();
</script>
<p class='graph-subtitle'> Source: WMATA Daily Disruption Reports via opendatadc.org.</p>
</div>
<p class='content'> The first half of 2015 had nearly twice as many delays compared to the same period in the past two years. <b>Year to date Metro delays total over eighteen days.</b> This is two and a half weeks. You could spend all your vacation days waiting for the Metro and still be waiting. This increase is partly due to a spike in delays this winter, but the spring and summer saw worse service as well.</p>
<div id="barchart2">
<p class='graph-title'>Monthly Metro Delays, January 2013 - July 2015<sup>*</sup></p>
<p class='graph-subtitle'> Number of delays reported on Metro monthly</p>
<svg class="chart2"></svg>
<script>
(function() {
var margin = {top: 20, right: 0, bottom: 17, left: 25},
width = 820- margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.outerTickSize(0)
.orient("left");
var chart2 = d3.select(".chart2")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.csv("https://raw.githubusercontent.com/katerabinowitz/Wmata-Delay/master/YM-Delays.csv", type, function(error, data) {
x.domain(data.map(function(d) { return d.YM; }));
y.domain([0, d3.max(data, function(d) { return d.DelayCountYM; })]);
chart2.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
chart2.append("g")
.attr("class", "y axis")
.call(yAxis);
chart2.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.YM); })
.attr("y", function(d) { return y(d.DelayCountYM); })
.attr("height", function(d) { return height - y(d.DelayCountYM); })
.attr("width", x.rangeBand());
});
function type(d) {
d.value = +d.value;
return d;
}
})();
</script>
<p class='graph-subtitle'> Source: WMATA Daily Disruption Reports via opendatadc.org.</p>
</div>
<p class="content"> It'd be nice if all these delays happened in the early hours of Sunday morning, since so many have long given up on taking the Metro anywhere on weekends. But the Metro is most likely to be delayed when you need it most. The heatmap below shows that delays are heavily concentrated just before and during commuting hours. Of course WMATA *tries* to run twice as many trains during rush hour. But there are more delays per train during that hour as well. Afterall, the benefit of more trains is debatable when you wait ten minutes for three trains to arrive at once.</p>
<p class='graph-title'>Average Metro Delays by Weekday and Hour, January 2015 - July 2015<sup>*</sup></p>
<p class='graph-subtitle'> Number of delays reported on Metro averaged by day of week and hour</p>
<div id="heatmap">
<script type="text/javascript">
(function() {
var margin = { top: 50, right: 0, bottom: 30, left: 30 },
width = 660 - margin.left - margin.right,
height = 340 - margin.top - margin.bottom,
gridSize = Math.floor(width / 24),
legendElementWidth = gridSize*2,
buckets = 9,
colors = ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],
days = ["Su","Mo", "Tu", "We", "Th", "Fr", "Sa"],
times = ["1a","2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12a", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p",'12p'];
d3.csv("https://raw.githubusercontent.com/katerabinowitz/Wmata-Delay/master/DT-Delays.csv",
function(d) {
return {
day: +d.Day,
hour: +d.HourN,
value: +d.V1
};
},
function(error, data) {
var colorScale = d3.scale.quantile()
.domain([0, 5.2])
.range(colors);
var svg = d3.select("#heatmap").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var dayLabels = svg.selectAll(".dayLabel")
.data(days)
.enter().append("text")
.text(function (d) { return d; })
.attr("x", 0)
.attr("y", function (d, i) { return i * gridSize; })
.style("text-anchor", "end")
.attr("transform", "translate(-6," + gridSize / 1.5 + ")")
.attr("class", function (d, i) { return ((i >= 1 && i <= 5) ? "dayLabel mono axis axis-workweek" : "dayLabel mono axis"); });
var timeLabels = svg.selectAll(".timeLabel")
.data(times)
.enter().append("text")
.text(function(d) { return d; })
.attr("x", function(d, i) { return i * gridSize; })
.attr("y", 0)
.style("text-anchor", "middle")
.attr("transform", "translate(" + gridSize / 2 + ", -6)")
.attr("class", function(d, i) { return ((i >= 6 && i <= 8 || i >= 16 && i <= 18) ? "timeLabel mono axis axis-worktime" : "timeLabel mono axis"); });
var heatMap = svg.selectAll(".hour")
.data(data)
.enter().append("rect")
.attr("x", function(d) { return (d.hour - 1) * gridSize; })
.attr("y", function(d) { return (d.day - 1) * gridSize; })
.attr("rx", 4)
.attr("ry", 4)
.attr("class", "hour bordered")
.attr("width", gridSize)
.attr("height", gridSize)
.style("fill", colors[0]);
heatMap.transition().duration(1000)
.style("fill", function(d) {return colorScale(d.value); });
heatMap.append("title").text(function(d) { return d.value; });
var legend = svg.selectAll(".legend")
.data([0].concat(colorScale.quantiles()), function(d) { return d; })
.enter().append("g")
.attr("class", "legend");
legend.append("rect")
.attr("x", function(d, i) { return legendElementWidth * i; })
.attr("y", height)
.attr("width", legendElementWidth)
.attr("height", gridSize / 2)
.style("fill", function(d, i) { return colors[i]; });
legend.append("text")
.attr("class", "mono")
.text(function(d) { return "≥ " + d.toFixed(2); })
.attr("x", function(d, i) { return legendElementWidth * i; })
.attr("y", height + gridSize);
});
})();
</script>
</div>
<br>
<div id="smheatmap">
<script>
(function() {
var margin = { top: 30, right: 25, bottom: 50, left: 50},
width = 700 - margin.left - margin.right,
height = 660 - margin.top - margin.bottom,
gridSize = Math.floor(height/ 24),
legendElementWidth = gridSize*1.5,
buckets = 9,
colors = ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],
days = ["Su","Mo", "Tu", "We", "Th", "Fr", "Sa"],
times = ["1a","2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12a", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p",'12p'];
d3.csv("https://raw.githubusercontent.com/katerabinowitz/Wmata-Delay/master/DT-Delays.csv",
function(d) {
return {
day: +d.Day,
hour: +d.HourN,
value: +d.V1
};
},
function(error, data) {
var colorScale = d3.scale.quantile()
.domain([0, 5.2])
.range(colors);
var svg = d3.select("#smheatmap").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var dayLabels = svg.selectAll(".dayLabel")
.data(days)
.enter().append("text")
.text(function (d) { return d; })
.attr("x", function (d, i) { return i * gridSize; })
.attr("y", 0)
.style("text-anchor", "middle")
.attr("transform", "translate(" + gridSize / 2 + ", -6)")
.attr("class", function (d, i) { return ((i >= 1 && i <= 5) ? "dayLabel mono axis axis-workweek" : "dayLabel mono axis"); });
var timeLabels = svg.selectAll(".timeLabel")
.data(times)
.enter().append("text")
.text(function(d) { return d; })
.attr("x", 0)
.attr("y", function(d, i) { return i * gridSize; })
.style("text-anchor", "end")
.attr("transform", "translate(-6," + gridSize / 1.5 + ")")
.attr("class", function(d, i) { return ((i >= 6 && i <= 8 || i >= 16 && i <= 18) ? "timeLabel mono axis axis-worktime" : "timeLabel mono axis"); });
var heatMap = svg.selectAll(".hour")
.data(data)
.enter().append("rect")
.attr("x", function(d) { return (d.day - 1) * gridSize; })
.attr("y", function(d) { return (d.hour - 1) * gridSize; })
.attr("rx", 4)
.attr("ry", 4)
.attr("class", "hour bordered")
.attr("width", gridSize)
.attr("height", gridSize)
.style("fill", colors[0]);
heatMap.transition().duration(1000)
.style("fill", function(d) {return colorScale(d.value); });
heatMap.append("title").text(function(d) { return d.value; });
var legend = svg.selectAll(".legend")
.data([0].concat(colorScale.quantiles()), function(d) { return d; })
.enter().append("g")
.attr("class", "legend");
legend.append("rect")
.attr("x", function(d, i) { return legendElementWidth * i; })
.attr("y", height)
.attr("width", legendElementWidth)
.attr("height", gridSize / 2)
.style("fill", function(d, i) { return colors[i]; });
legend.append("text")
.attr("class", "mono")
.text(function(d) { return "≥ " + d.toFixed(1); })
.attr("x", function(d, i) { return legendElementWidth * i; })
.attr("y", height + gridSize);
});
})();
</script>
</div>
<p class='graph-subtitle'> Source: WMATA Daily Disruption Reports via opendatadc.org.</p>
<p class='content'> I'm not sure how Metro will improve with all the <a class='link' target="_blank" href="http://www.washingtonpost.com/local/trafficandcommuting/metros-financial-woes-could-mean-trouble-for-the-agency-in-june/2015/05/08/d9483288-f59c-11e4-b2f3-af5479e6bbdd_story.html">money it doesn't have</a>, but on the upside there are only more delays, not longer delays. And on an (un)related note DC keeps <a class='link'href="http://greatergreaterwashington.org/post/25828/dc-streets-will-get-seven-new-miles-of-bikeways-in-2015/">expanding bike lanes...</a></p>
<hr id='end-line'>
<p class='content'><b>Technical notes:</b> Graphics are based on WMATA Disruption reports. <a class='link' target="_blank" href="http://codefordc.org/">Code for DC</a> has wonderfully scraped these reports in easy-to-analyze CSV files at <a class="link" target="_blank"href="http://www.opendatadc.org/">opendatadc.org</a>. You can find complete code for this post<a class='link' target="_blank" href="https://github.com/katerabinowitz"> on my github page.</a></p>
<p class='content'><sup>*</sup>Data for July 2015 only goes to July 24th. So the numbers are likely even worse!
<br><br>