Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Afghanistan threat reports
#!/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
You can’t perform that action at this time.