import matplotlib.pyplot as plt

# KROK 2.
LEGEND = ('ProduktA', 'ProduktB', 'ProduktC')
DATA = (
    ('I kw. 2017 r.', 100, 30, 3),
    ('II kw. 2017 r.', 105, 32, 15),
    ('III kw. 2017 r.', 125, 29, 40),
    ('IV kw. 2017 r.', 115, 31, 80),
)

# KROK 3.
POS = list(range(len(DATA)))
VALUESA = [valueA for label, valueA, valueB, valueC in DATA]
VALUESB = [valueB for label, valueA, valueB, valueC in DATA]
VALUESC = [valueC for label, valueA, valueB, valueC in DATA]
LABELS = [label for label, valueA, valueB, valueC in DATA]

# KROK 4.
WIDTH = 0.2
valueA = plt.bar([p - WIDTH for p in POS], VALUESA, width=WIDTH)
valueB = plt.bar([p for p in POS], VALUESB, width=WIDTH)
valueC = plt.bar([p + WIDTH for p in POS], VALUESC, width=WIDTH)
plt.ylabel('Sprzedaż')
plt.xticks(POS, LABELS)

# KROK 5.
plt.annotate('Wzrost 400%', xy=(1.2, 18), xytext=(1.3, 40),
             horizontalalignment='center',
             fontsize=9,
             arrowprops={'facecolor': 'black',
                         'arrowstyle': "fancy",
                         'connectionstyle': "angle3",
                         })

# KROK 6.
# Wyświetlanie legendy poza wykresem.
plt.legend(LEGEND, title='Produkty', bbox_to_anchor=(1, 0.8))
plt.subplots_adjust(right=0.80)

# KROK 6.
plt.show()
