-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathViewCount Graph.py
More file actions
33 lines (28 loc) · 846 Bytes
/
ViewCount Graph.py
File metadata and controls
33 lines (28 loc) · 846 Bytes
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
import pymysql
db = pymysql.connect("localhost","root","PASSWD","Android")
cursor = db.cursor()
import matplotlib.pyplot as plt
cursor.execute("SELECT ViewCount FROM Posts")
result = cursor.fetchall()
l1 = []
for i in range(0,len(result)) :
l1.append(result[i][0])
l2 = sorted(l1,reverse = True)
l3 = []
for i in range(len(l2)) :
l3.append(i)
l4 = list(set(l2))
xmin = 0
xmax = 80000
ymin = 0
ymax = 550000
axes = plt.gca()
axes.set_xlim([xmin,xmax])
axes.set_ylim([ymin,ymax])
plt.plot(l1,'-b',linewidth = 3,label = "post views")
plt.legend(fontsize = 21)#, weight = 'bold')
plt.xticks(fontsize = 21, fontweight = 'semibold')
plt.yticks(fontsize = 21,fontweight = 'semibold')
plt.xlabel("Post Id", fontsize = 21,fontweight = 'semibold',fontname = 'Times New Roman')
plt.ylabel("Post Id", fontsize = 21,fontweight = 'semibold')
plt.show()