You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #####################################
  4. #
  5. # This program source code file is part of KiCad, a free EDA CAD application.
  6. #
  7. # Copyright (C) 2016 Nick Østergaard <oe.nick at gmail dot com>
  8. # Copyright (C) 2016 KiCad Developers
  9. #
  10. # License GNU GPL Version 3 or any later version.
  11. #
  12. #####################################
  13. import matplotlib.pyplot as plt
  14. import csv
  15. import numpy as np
  16. import time
  17. # Initialize data structure variable
  18. data = []
  19. # Read CSV file
  20. with open('i18n_status.csv', 'r') as csvfile:
  21. spamreader = csv.reader(csvfile, delimiter=';')
  22. for row in spamreader:
  23. data.append(row)
  24. # Replace empyt values with zero and convert numbers to int
  25. for index,value in np.ndenumerate( data ):
  26. if value=='':
  27. data[index[0]][index[1]] = 0
  28. try:
  29. data[index[0]][index[1]] = int(data[index[0]][index[1]])
  30. except:
  31. pass
  32. # Sort data after mostly translated
  33. data[1:] = sorted(data[1:], key=lambda x: int(x[1]), reverse=True)
  34. # Prepare some number for formatting the plot
  35. N = len(data[1:]) # number of languages
  36. width = 0.35 # the width of the bars
  37. ind = np.arange(N)*width*5 # the x locations for the groups
  38. # Plot the bars
  39. fig, ax = plt.subplots()
  40. rects1 = ax.bar(ind, list(zip(*data))[1][1:], width, color='b')
  41. rects2 = ax.bar(ind+width, list(zip(*data))[2][1:], width, color='r')
  42. rects3 = ax.bar(ind+2*width, list(zip(*data))[3][1:], width, color='y')
  43. # Plot ceiling
  44. max_nof_strings = sum(map(int, data[1][1:4]))
  45. plt.plot([0,max(ind)+3*width],[max_nof_strings,max_nof_strings], color='k', linewidth='2')
  46. ax.set_xlim([0,max(ind)+3*width])
  47. # Add some text for labels, title and axes ticks
  48. ax.set_ylabel('Number of strings')
  49. ax.set_title('Translation status')
  50. ax.set_xticks(ind+width*1.5)
  51. ax.set_xticklabels(list(zip(*data))[0][1:])
  52. ax.yaxis.grid(True, which='both') # horizontal lines
  53. ax.legend((rects1[0], rects2[0], rects3[0]), ('TRANSLATED', 'FUZZY', 'UNTRANSLATED'), loc='upper center', bbox_to_anchor=(0.5, -0.05), fancybox=True, ncol=3)
  54. plt.figtext(0.99, 0.96, time.strftime("%d/%m %Y"), horizontalalignment='right')
  55. plt.subplots_adjust(left=0.07, right=0.99, top=0.95, bottom=0.12)
  56. fig.set_size_inches(12, 8)
  57. fig.savefig('i18n_status.svg')
  58. # Show the magic to the user
  59. plt.show()