Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- from datetime import datetime
- import matplotlib.pyplot as plt
- import numpy
- num_authors = [36, 36, 31, 32, 30, 32, 44, 49, 39, 42, 39, 30, 29, 36, 31, 25, 22, 21, 20, 18, 19, 23, 16, 13, 11, 12, 12, 13, 16, 15, 11, 13, 12, 12, 11, 9]
- commits = [1104, 1249, 838, 895, 912, 1070, 1667, 1102, 1358, 1563, 1251, 746, 958, 1235, 1123, 780, 636, 932, 664, 1031, 710, 829, 860, 666, 885, 1030, 485, 815, 1138, 811,1042, 1024, 1141, 1001, 1071, 835]
- dates = [
- "12/1/2016","11/1/2016","10/1/2016","9/1/2016","8/1/2016","7/1/2016","6/1/2016","5/1/2016","4/1/2016","3/1/2016","2/1/2016","1/1/2016","12/1/2015","11/1/2015","9/1/2015","8/1/2015","7/1/2015","6/1/2015","5/1/2015","4/1/2015","3/1/2015","2/1/2015","1/1/2015","12/1/2014","11/1/2014","10/1/2014","9/1/2014","8/1/2014","7/1/2014","6/1/2014","5/1/2014","4/1/2014","3/1/2014","2/1/2014","1/1/2014","12/1/2013"]
- dates = map(lambda date: datetime.strptime(date, '%m/%d/%Y'), dates)
- commits_per_author = []
- for i in range(0, len(num_authors)):
- commits_per_author.append(commits[i] / num_authors[i])
- # fit with a polynomial factor of 2
- z = numpy.polyfit(range(0, len(commits_per_author)), commits_per_author, 2)
- p = numpy.poly1d(z)
- plt.style.use('fivethirtyeight')
- plt.gcf().autofmt_xdate()
- plt.figure(figsize=(14,8))
- plt.title('Commits Per Author Over Time')
- plt.ylabel('Commits/Author')
- plt.plot(dates, commits_per_author, '-', dates, p(range(0, len(commits_per_author))), '--')
- # plt.show()
- plt.savefig('CommitsPerAuthor.png')
Add Comment
Please, Sign In to add comment