Plotting uploads/day
We are beta testing a HTML5 Uploader, and I wanted to see how much use it was getting. Here is how I plotted the usage. First, install ipython html notebook, then install matplotlib 1.3rc2 to use the xkcd style, then start iPython notebook:
$ source ~/pyenvs/notebook/bin/activate $ ipython notebook --profile=nbserver |
Then, in iPython notebook, use the archive.org advanced search engine to see how many uploads per day we were getting:
import json import urllib import datetime as dt x=[] y=[] urlbase = 'http://archive.org/advancedsearch.php?%s' date = dt.datetime.utcnow() for i in range(90): date -= dt.timedelta(days=1) x.append(date) params = {'q':'scanner:"Internet Archive HTML5 Uploader" AND publicdate:'+date.strftime('%Y-%m-%d'), 'fl[]':'identifier', 'rows':1, 'output':'json' } url = urlbase % urllib.urlencode(params) f = urllib.urlopen(url) o = json.load(f) y.append(o['response']['numFound']) |
Now that I have the data, I can plot it, using xkcd-style:
#Turn on XKCD style plt.xkcd() plot(x, y) plt.title("HTML Uploader Items/Day") plt.xticks(rotation=75) #Save PNG fig = plt.gcf() subplots_adjust(bottom=0.3) plt.savefig('out.png',dpi=100) |
It looks like this:
Reply