import matplotlib
import matplotlib.pyplot as plt
import numpy as np


STATS = (
    ("Lib", 2765),
    ("Doc", 1342),
    ("Misc", 1322),
    ("Modules", 1294),
    ("Python", 797),
    ("Objects", 705),
    ("Include", 533),
    ("Tools", 308),
    ("Parser", 223),
    ("PCbuild", 176),
    ("PC", 83),
    (".github", 58),
    ("Grammar", 43),
    (".azure-pipelines", 37),
    ("Mac", 35),
    ("Programs", 15),
    ("m4", 2),
)

plt.rcdefaults()
fig, ax = plt.subplots()
fig.subplots_adjust(left=0.2)

labels = [label for label, _ in STATS]
y_pos = np.arange(len(STATS))
quantites = [qte for _, qte in STATS]

ax.barh(y_pos, quantites, align='center')
ax.set_yticks(y_pos)
ax.set_yticklabels(labels)
ax.invert_yaxis()  # labels read top-to-bottom
ax.set_xlabel('Modifications et ajouts de fichier')
ax.set_title('Changements en 2020')

#plt.show()
plt.savefig("commits-2020-cpython.png")

