-
Notifications
You must be signed in to change notification settings - Fork 0
/
histograms_users_received_all.py
233 lines (208 loc) · 10.5 KB
/
histograms_users_received_all.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Loading the required libraries
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
import powerlaw
# Function to create histograms
def histplot(data, binsize, ylab, xlab, color, title):
plt.hist(data, density=False, bins=binsize, color=color, fill=False, histtype='step')
plt.yscale('log')
plt.xscale('log')
plt.xlim(left=1)
plt.ylabel(ylab)
plt.xlabel(xlab)
plt.title(title)
# Set the working directory
wd = os.getcwd() + '\\received\\'
# Reading in CSVs with the data for the histograms
russian_all = pd.read_csv(wd + "russian_users_received_all.csv", encoding = "ISO-8859-1", engine='python')
chinese_all = pd.read_csv(wd + "chinese_users_received_all.csv", encoding = "ISO-8859-1", engine='python')
american_all = pd.read_csv(wd + "unitedstates_users_received_all.csv", encoding = "ISO-8859-1", engine = 'python')
indian_all = pd.read_csv(wd + "indian_users_received_all.csv", encoding = "ISO-8859-1", engine = 'python')
russian_6_star = pd.read_csv(wd + "russian_stars_received_6_months.csv", encoding = "ISO-8859-1", engine='python')
chinese_6_star = pd.read_csv(wd + "chinese_stars_received_6_months.csv", encoding = "ISO-8859-1", engine='python')
american_6_star = pd.read_csv(wd + "unitedstates_stars_received_6_months.csv", encoding = "ISO-8859-1", engine = 'python')
indian_6_star = pd.read_csv(wd + "indian_stars_received_6_months.csv", encoding = "ISO-8859-1", engine = 'python')
russian_6_fork = pd.read_csv(wd + "russian_forks_received_6_months.csv", encoding = "ISO-8859-1", engine='python')
chinese_6_fork = pd.read_csv(wd + "chinese_forks_received_6_months.csv", encoding = "ISO-8859-1", engine='python')
american_6_fork = pd.read_csv(wd + "unitedstates_forks_received_6_months.csv", encoding = "ISO-8859-1", engine = 'python')
indian_6_fork = pd.read_csv(wd + "indian_forks_received_6_months.csv", encoding = "ISO-8859-1", engine = 'python')
# Putting the data into list form and popping the zeros off
russian_followers_all = russian_all['follower_count'].tolist()
chinese_followers_all = chinese_all['follower_count'].tolist()
american_followers_all = american_all['follower_count'].tolist()
indian_followers_all = indian_all['follower_count'].tolist()
russian_followers_all = [i for i in russian_followers_all if i != 0]
chinese_followers_all = [i for i in chinese_followers_all if i != 0]
american_followers_all = [i for i in american_followers_all if i != 0]
indian_followers_all = [i for i in indian_followers_all if i != 0]
russian_watchers_all = russian_all['watcher_count'].tolist()
chinese_watchers_all = chinese_all['watcher_count'].tolist()
american_watchers_all = american_all['watcher_count'].tolist()
indian_watchers_all = indian_all['watcher_count'].tolist()
russian_watchers_all = [i for i in russian_watchers_all if i != 0]
chinese_watchers_all = [i for i in chinese_watchers_all if i != 0]
american_watchers_all = [i for i in american_watchers_all if i != 0]
indian_watchers_all = [i for i in indian_watchers_all if i != 0]
russian_forkers_all = russian_all['fork_count'].tolist()
chinese_forkers_all = chinese_all['fork_count'].tolist()
american_forkers_all = american_all['fork_count'].tolist()
indian_forkers_all = indian_all['fork_count'].tolist()
russian_forkers_all = [i for i in russian_forkers_all if i != 0]
chinese_forkers_all = [i for i in chinese_forkers_all if i != 0]
american_forkers_all = [i for i in american_forkers_all if i != 0]
indian_forkers_all = [i for i in indian_forkers_all if i != 0]
chinese_6_star = chinese_6_star['star_count'].tolist()
american_6_star = american_6_star['star_count'].tolist()
indian_6_star = indian_6_star['star_count'].tolist()
russian_6_star = russian_6_star['star_count'].tolist()
chinese_6_fork = chinese_6_fork['fork_count'].tolist()
american_6_fork = american_6_fork['fork_count'].tolist()
indian_6_fork = indian_6_fork['fork_count'].tolist()
russian_6_fork = russian_6_fork['fork_count'].tolist()
# Deriving the bin size from the largest value in the set
binsize = int(np.max(russian_followers_all))
# Plotting the first line
histplot(russian_followers_all, binsize, 'Users', 'Follower count', 'black', '')
# Repeating the process for the rest of the data
binsize = int(np.max(chinese_followers_all))
histplot(chinese_followers_all, binsize, 'Users', 'Follower count', 'red', '')
binsize = int(np.max(american_followers_all))
histplot(american_followers_all, binsize, 'Users', 'Follower count', 'blue', '')
binsize = int(np.max(indian_followers_all))
histplot(indian_followers_all, binsize, 'Users', 'Follower count', 'green', 'User All Follows Received by Count, LogLog Scale Plot')
plt.savefig('logscale_all_follow_received.png')
plt.close()
binsize = int(np.max(russian_watchers_all))
histplot(russian_watchers_all, binsize, 'Users', 'Star count', 'black', '')
binsize = int(np.max(chinese_watchers_all))
histplot(chinese_watchers_all, binsize, 'Users', 'Star count', 'red', '')
binsize = int(np.max(american_watchers_all))
histplot(american_watchers_all, binsize, 'Users', 'Star count', 'blue', '')
binsize = int(np.max(indian_watchers_all))
histplot(indian_watchers_all, binsize, 'Users', 'Star count', 'green', 'User All Stars Received by Count, LogLog Scale Plot')
plt.savefig('logscale_all_stars_received.png')
plt.close()
binsize = int(np.max(russian_forkers_all))
histplot(russian_forkers_all, binsize, 'Users', 'Fork count', 'black', '')
binsize = int(np.max(chinese_forkers_all))
histplot(chinese_forkers_all, binsize, 'Users', 'Fork count', 'red', '')
binsize = int(np.max(american_forkers_all))
histplot(american_forkers_all, binsize, 'Users', 'Fork count', 'blue', '')
binsize = int(np.max(indian_forkers_all))
histplot(indian_forkers_all, binsize, 'Users', 'Fork count', 'green', 'User All Forks Received by Count, LogLog Scale Plot')
plt.savefig('logscale_all_forks_received.png')
plt.close()
multiplier = 7
binsize = int(np.max(russian_6_star)/5)
histplot(russian_6_star, binsize, 'Users', 'Star count', 'black', '')
binsize = int(np.max(chinese_6_star)/multiplier)
histplot(chinese_6_star, binsize, 'Users', 'Star count', 'red', '')
binsize = int(np.max(american_6_star)/multiplier)
histplot(american_6_star, binsize, 'Users', 'Star count', 'blue', '')
binsize = int(np.max(indian_watchers_all)/multiplier)
histplot(indian_6_star, binsize, 'Users', 'Star count', 'green', 'User Jan-Jun 2019 Stars Received by Count, LogLog Scale Plot')
plt.savefig('logscale_jan-jun_stars_received.png')
plt.close()
multiplier = 6
binsize = int(np.max(russian_6_fork)/multiplier)
histplot(russian_6_fork, binsize, 'Users', 'Fork count', 'black', '')
binsize = int(np.max(chinese_6_fork)/multiplier)
histplot(chinese_6_fork, binsize, 'Users', 'Fork count', 'red', '')
binsize = int(np.max(american_forkers_all)/multiplier)
histplot(american_6_fork, binsize, 'Users', 'Fork count', 'blue', '')
binsize = int(np.max(indian_6_fork)/multiplier)
histplot(indian_6_fork, binsize, 'Users', 'Fork count', 'green', 'User Jan-Jun 2019 Forks Received by Count, LogLog Scale Plot')
plt.savefig('logscale_jan-jun_forks_received.png')
plt.close()
powerlaw.plot_pdf(russian_followers_all, color='black')
powerlaw.plot_pdf(chinese_followers_all, color='red')
powerlaw.plot_pdf(american_followers_all, color='blue')
powerlaw.plot_pdf(indian_followers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Follow Count')
plt.title('All Follows Received by Count, PDF')
plt.savefig('pdf_all_follows_received.png')
plt.close()
powerlaw.plot_ccdf(russian_followers_all, color='black')
powerlaw.plot_ccdf(chinese_followers_all, color='red')
powerlaw.plot_ccdf(american_followers_all, color='blue')
powerlaw.plot_ccdf(indian_followers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Follow Count')
plt.title('All Follows Received by Count, CCDF')
plt.savefig('ccdf_all_follows_received.png')
plt.close()
powerlaw.plot_pdf(russian_watchers_all, color='black')
powerlaw.plot_pdf(chinese_watchers_all, color='red')
powerlaw.plot_pdf(american_watchers_all, color='blue')
powerlaw.plot_pdf(indian_watchers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Star Count')
plt.title('All Stars Received by Count, PDF')
plt.savefig('pdf_all_stars_received.png')
plt.close()
powerlaw.plot_ccdf(russian_watchers_all, color='black')
powerlaw.plot_ccdf(chinese_watchers_all, color='red')
powerlaw.plot_ccdf(american_watchers_all, color='blue')
powerlaw.plot_ccdf(indian_watchers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Star Count')
plt.title('All Stars Received by Count, CCDF')
plt.savefig('ccdf_all_stars_received.png')
plt.close()
powerlaw.plot_pdf(russian_forkers_all, color='black')
powerlaw.plot_pdf(chinese_forkers_all, color='red')
powerlaw.plot_pdf(american_forkers_all, color='blue')
powerlaw.plot_pdf(indian_forkers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Fork Count')
plt.title('All Forks Received by Count, PDF')
plt.savefig('pdf_all_forks_received.png')
plt.close()
powerlaw.plot_ccdf(russian_forkers_all, color='black')
powerlaw.plot_ccdf(chinese_forkers_all, color='red')
powerlaw.plot_ccdf(american_forkers_all, color='blue')
powerlaw.plot_ccdf(indian_forkers_all, color='green')
plt.ylabel('Users')
plt.xlabel('Fork Count')
plt.title('All Forks Received by Count, CCDF')
plt.savefig('ccdf_all_forks_received.png')
plt.close()
powerlaw.plot_pdf(russian_6_star, color='black')
powerlaw.plot_pdf(chinese_6_star, color='red')
powerlaw.plot_pdf(american_6_star, color='blue')
powerlaw.plot_pdf(indian_6_star, color='green')
plt.ylabel('Users')
plt.xlabel('Star Count')
plt.title('Jan-Jun 2019 Stars Received by Count, PDF')
plt.savefig('pdf_jan-jun_stars_received.png')
plt.close()
powerlaw.plot_ccdf(russian_6_star, color='black')
powerlaw.plot_ccdf(chinese_6_star, color='red')
powerlaw.plot_ccdf(american_6_star, color='blue')
powerlaw.plot_ccdf(indian_6_star, color='green')
plt.ylabel('Users')
plt.xlabel('Star Count')
plt.title('Jan-Jun 2019 Stars Received by Count, CCDF')
plt.savefig('ccdf_jan-jun_stars_received.png')
plt.close()
powerlaw.plot_pdf(russian_6_fork, color='black')
powerlaw.plot_pdf(chinese_6_fork, color='red')
powerlaw.plot_pdf(american_6_fork, color='blue')
powerlaw.plot_pdf(indian_6_fork, color='green')
plt.ylabel('Users')
plt.xlabel('Fork Count')
plt.title('Jan-Jun 2019 Forks Received by Count, PDF')
plt.savefig('pdf_Jan-Jun_forks_received.png')
plt.close()
powerlaw.plot_ccdf(russian_6_fork, color='black')
powerlaw.plot_ccdf(chinese_6_fork, color='red')
powerlaw.plot_ccdf(american_6_fork, color='blue')
powerlaw.plot_ccdf(indian_6_fork, color='green')
plt.ylabel('Users')
plt.xlabel('Fork Count')
plt.title('Jan-Jun 2019 Forks Received by Count, CCDF')
plt.savefig('ccdf_jan-jun_forks_received.png')
plt.close()