У меня есть следующий набор данных, и я построил гистограмму с накоплением, используя Matplotlib.
industry Distribution Manufacturing Retail Services
2017-09 1 4 12 7
2017-10 3 2 3 4
2017-11 1 0 2 1
2018-02 1 0 0 0
Ниже приведен код для создания графика:
fig, ax = plt.subplots(1, figsize=(17,6))
part1 = ax.bar(industry_split.index.values, 'Retail', data=industry_split, color = 'darkblue', width=0.5, edgecolor=edgecolor, linewidth=linewidth)
part2 = ax.bar(industry_split.index.values, 'Services', data=industry_split, color = 'dodgerblue', edgecolor=edgecolor, linewidth=linewidth, width=0.5, bottom = industry_split.Retail)
part3 = ax.bar(industry_split.index.values, 'Manufacturing', data=industry_split, color = 'green', width=0.5, edgecolor=edgecolor, linewidth=linewidth, bottom = industry_split.Retail + industry_split.Services)
part4 = ax.bar(industry_split.index.values, 'Distribution', data=industry_split, color = 'orange', width=0.5, edgecolor=edgecolor, linewidth=linewidth, bottom = industry_split.Retail + industry_split.Services + industry_split.Manufacturing)
Мне нужно аннотировать значения на графике. Например, мне нужно, чтобы значение каждой полосы отображалось внутри полосы графика. См. Пример ниже