Skip to content

Instantly share code, notes, and snippets.

@jobliz
Created August 6, 2012 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jobliz/3269061 to your computer and use it in GitHub Desktop.
Save jobliz/3269061 to your computer and use it in GitHub Desktop.
import csv
import pylab as p
data = [r for r in csv.reader(open('piratebay.csv', 'rb'))]
def categoryratio(c):
return sum([ int(r[3]) for r in data if r[1][0] == str(c) ])
# Adapted from # http://scienceoss.com/bar-plot-with-custom-axis-labels/
fig = p.figure()
ax = fig.add_subplot(1,1,1)
y = map(categoryratio, list(xrange(1, 7)))
N = len(y)
ind = range(N)
ax.bar(ind, y, facecolor='green', align='center', ecolor='black')
ax.set_ylabel('Total Seeds')
ax.set_title('Piratebay Seeding by Category',fontstyle='italic')
ax.set_xticks(ind)
group_labels = ['Music', 'Videos', 'Apps', 'Games', 'Porn', 'Other']
ax.set_xticklabels(group_labels)
fig.autofmt_xdate()
p.show()
import csv
import pylab as p
data = [r for r in csv.reader(open('piratebay.csv', 'rb'))]
def categorysize(c):
return sum([int(r[2]) for r in data if r[1][0] == str(c)]) / (2**30) #GiB
# Adapted from # http://scienceoss.com/bar-plot-with-custom-axis-labels/
fig = p.figure()
ax = fig.add_subplot(1,1,1)
y = map(categorysize, list(xrange(1, 7)))
N = len(y)
ind = range(N)
ax.bar(ind, y, facecolor='#777777', align='center', ecolor='black')
ax.set_ylabel('GiB')
ax.set_title('Piratebay Category Total Size',fontstyle='italic')
ax.set_xticks(ind)
group_labels = ['Music', 'Videos', 'Apps', 'Games', 'Porn', 'Other']
ax.set_xticklabels(group_labels)
fig.autofmt_xdate()
p.show()
import csv
import matplotlib.pyplot as plt
data = lambda: csv.reader(open('piratebay.csv', 'rb'))
seeders = [i[3] for i in data()][1:]
leechers = [i[4] for i in data()][1:]
plt.plot(seeders, leechers, 'ro')
plt.xlabel('Number of Seeders')
plt.ylabel('Numbers of Leechers')
plt.title('Seeders/Leechers ratio')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment