plot_types.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import matplotlib.pyplot as plt
  2. class TypePlotter:
  3. def __init__(self, data, years):
  4. self.src2dsa = data.src2dsa
  5. self.dsa2cve = data.dsa2cve
  6. self.cvetable = data.cvetable
  7. self.pkg_with_cvss = data.pkg_with_cvss
  8. self.src2cwe = data.src2cwe
  9. self.years = years
  10. def plot_types(self):
  11. src2cwe_sum = []
  12. for i in range(0, 12*self.years):
  13. src2cwe_sum.append([0]*12)
  14. for pkg in self.src2cwe:
  15. for i in range(len(self.src2cwe[pkg])):
  16. for j in range(len(self.src2cwe[pkg][i])):
  17. src2cwe_sum[i][j] += self.src2cwe[pkg][i][j]
  18. src2cwe_sumofsums = [0]*12
  19. for month in src2cwe_sum:
  20. for j in range(len(month)):
  21. src2cwe_sumofsums[j] += month[j]
  22. print(src2cwe_sumofsums)
  23. cwe2month = dict()
  24. for j in range(12):
  25. cwe2month[j] = []
  26. for month in src2cwe_sum:
  27. for j in range(len(month)):
  28. cwe2month[j].append(month[j])
  29. print(cwe2month[1])
  30. print(sum(cwe2month[1]))
  31. for i in range(12):
  32. binned = []
  33. for j in range(self.years*3):
  34. binned.append(sum(cwe2month[i][4*j:4*j+4]))
  35. plt.plot(binned)
  36. plt.show()
  37. return 0