Created
July 2, 2016 02:00
-
-
Save waltercruz/c6b6c0dc577efbe65d598d94b4cd05aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict, Counter | |
from pprint import pprint | |
import json | |
import matplotlib.pyplot as plt | |
plt.rcdefaults() | |
from matplotlib import rcParams | |
rcParams.update({'figure.autolayout': True}) | |
import numpy as np | |
subs = defaultdict(lambda: 0) | |
data = open ('data.txt') | |
for i in data: | |
items = i.replace("\n","").split(' ') | |
for item in items: | |
subs[item] += 1 | |
labels = [] | |
values = [] | |
for w in sorted(subs, key=subs.get, reverse=True): | |
labels.append(w) | |
values.append(subs[w]) | |
limit = 30 | |
y_pos = np.arange(len(labels[0:limit]))[::-1] | |
plt.barh(y_pos, values[0:limit]) | |
plt.yticks(y_pos, labels[0:limit]) | |
plt.xlabel('Subs') | |
plt.title('Principais subs visitados') | |
plt.savefig('graph.png', dpi=300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment