# Informatics Showcase example: plotting Birthrate data
from mod_python import util
import urllib
import re
from pylab import *
proxies = {}
data_url = 'http://unstats.un.org/unsd/cdb/cdb_years_on_top.asp?srID=14870&crID=36&'
data_url = data_url + 'yrID=1996%2C1997%2C1998%2C1999%2C2000%2C2001%2C2002%2C2003'
f = urllib.urlopen(data_url, proxies=proxies)
html_data = f.read()
result = re.findall(r'
(.+?) | ', html_data)
arrData = []
for x in result:
x = x.replace(',','')
arrData.append( float(x)-200000 )
N = 8
clf()
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
p1 = bar(ind, arrData, width, bottom=0, color='r')
ylabel('Number of Birth (+200000)')
title('Can government tell us when to make babies?\n(The impact of baby bonus introduced in 2001)')
xticks(ind+width, ('1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003') )
savefig('/usr/project1/unstat.svg')
req.content_type = "text/html"
req.write('')
req.write('