Skip to content

Instantly share code, notes, and snippets.

@fnielsen
Created May 12, 2011 17:08
Show Gist options
  • Save fnielsen/968961 to your computer and use it in GitHub Desktop.
Save fnielsen/968961 to your computer and use it in GitHub Desktop.
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