-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_ratings.py
38 lines (32 loc) · 925 Bytes
/
plot_ratings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import matplotlib.pyplot as plt
import numpy as np
handles = []; ratings = []
f = open('/Users/charansrikar/Documents/Automation/Codeforces API/CF_User_ratings.txt', 'r')
lines = f.readlines()
for line in lines:
a , b = line.split(' ')
handles.append(a)
ratings.append(b.strip())
freq = {}
for j in range(-50, 4001):
freq[j] = 0
for j in ratings:
freq[int(j)] = freq[int(j)] + 1
x = []; y = []
for keys in freq:
x.append(keys)
y.append(freq[keys])
f = open('Rating_vs_Freq.txt', 'x')
for i in range(0, len(x)):
s = str(x[i]) + ' ' + str(y[i]) + '\n'
f.write(s)
plt.plot(x,y)
plt.xlim([-50, 3950])
plt.ylim([0, 1950])
plt.xticks(np.arange(-50, 3950, 400))
plt.yticks(np.arange(0, 1950, 150))
plt.xlabel('Rating')
plt.ylabel('frequency')
plt.title('User Ratings vs Freq')
#plt.show()
plt.savefig('/Users/charansrikar/Documents/Automation/Codeforces API/CF_ratings_plot.png', dpi= 1200)