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


STATS = (
    ("clinic", 134),
    ("_sqlite", 78),
    ("_decimal", 73),
    ("_io", 63),
    ("posixmodule.c", 57),
    ("_ctypes", 53),
    ("_testcapimodule.c", 39),
    ("gcmodule.c", 28),
    ("mathmodule.c", 25),
    ("signalmodule.c", 23),
    ("_functoolsmodule.c", 22),
    ("_asynciomodule.c", 21),
    ("_tracemalloc.c", 20),
    ("cjkcodecs", 19),
)

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('Les 14 premiers modifications et ajouts de fichier')
ax.set_title('Activités dans Modules/ en 2020')

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

