Created
May 12, 2011 17:08
-
-
Save fnielsen/968961 to your computer and use it in GitHub Desktop.
Afghanistan threat reports
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
#!/usr/bin/env python | |
# | |
# $Id: Wehner2011Trusselrapporter.py,v 1.3 2011/05/12 17:07:21 fn Exp $ | |
import csv | |
from pylab import * | |
from urllib import urlopen | |
url = 'http://data.information.dk/warlogs/afghanistan/data/wl_threat_reports.csv' | |
data = [] | |
header = [] | |
for row in csv.reader(urlopen(url)): | |
if not header: | |
header = row | |
continue | |
data.append(row) | |
years = [ int(d[4][:4]) for d in data ] | |
yearbins = arange(2004,2011) | |
count, dummy, patches = hist(years, | |
bins=yearbins-0.5, | |
rwidth=0.8, | |
facecolor=(0.5, 1, 0)) | |
for n in range(len(yearbins)): | |
text(yearbins[n], count[n]+100, str(count[n]), | |
horizontalalignment='center') | |
xticks(yearbins, yearbins) | |
xlabel('Year') | |
ylabel('Number of threat reports') | |
title('Afghanistan threat reports ') | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment