Guest User

Untitled

a guest
Feb 25th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import math
  2. from datetime import datetime
  3. import matplotlib.pyplot as plt
  4. import numpy
  5.  
  6. 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]
  7.  
  8. 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]
  9.  
  10. dates = [
  11. "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"]
  12. dates = map(lambda date: datetime.strptime(date, '%m/%d/%Y'), dates)
  13.  
  14. commits_per_author = []
  15. for i in range(0, len(num_authors)):
  16. commits_per_author.append(commits[i] / num_authors[i])
  17.  
  18. # fit with a polynomial factor of 2
  19. z = numpy.polyfit(range(0, len(commits_per_author)), commits_per_author, 2)
  20. p = numpy.poly1d(z)
  21.  
  22. plt.style.use('fivethirtyeight')
  23. plt.gcf().autofmt_xdate()
  24. plt.figure(figsize=(14,8))
  25.  
  26. plt.title('Commits Per Author Over Time')
  27. plt.ylabel('Commits/Author')
  28. plt.plot(dates, commits_per_author, '-', dates, p(range(0, len(commits_per_author))), '--')
  29. # plt.show()
  30. plt.savefig('CommitsPerAuthor.png')
Add Comment
Please, Sign In to add comment