Как изменить цвета в сгруппированном барплоте? - PullRequest
0 голосов
/ 16 апреля 2020

У меня есть этот код для отображения общего объема продаж определенного продукта в месяц в течение трех разных лет:

#plt.figure(figsize=())
p = [1, 0, -1]
pos = 0
for i in np.sort(item_20949.year.unique()):
    x = item_20949.month[item_20949.year == i].unique()
    x = np.sort(x)
    y = item_20949[item_20949.year == i].groupby('month').sum().item_cnt_day

    #x = np.arange(len(x))  # label locations
    width = 0.4  # width of the bars

    plt.bar(x + p[pos] * width/2, y, width/2, label= str(i))

    pos += 1

    plt.xlabel('mes')
    plt.ylabel('cantidad de unidades vendidas')
    plt.legend()

#plt.savefig('image_data/pete2')

plt.show()

And this is the output

Но что я пытаюсь сделать, чтобы изменить цвета для каждой группы.

...