0

I need your help. I am practicing data analysis and now I am trying to visualize my findings.

May I know how to align the label to their respective barplot, I want them to be at the top position of the barplot.

enter image description here

I hope someone can help me in this one. Thank you in advance

medium-dimensional
  • 1,974
  • 10
  • 19
Jj Encrypt
  • 11
  • 5

1 Answers1

0

This code helps bar alignment and adds a label above it.

sns.set()

labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']
entra_engaged = entra_total_engaged['TOTAL ENGAGED ENTRA']
entra_conversion = entra_total_conversion['TOTAL CONVERSION ENTRA']

x = np.arange(len(labels))
width = 0.4

fig, ax = plt.subplots(figsize=(18,8))
rects1 = ax.bar(x - width/2, entra_engaged, width,label='Engage')
rects2 = ax.bar(x + width/2, entra_conversion, width, label='Conversion')

ax.set_ylabel('Total')
ax.set_title('MILK')
ax.set_xticks(x, labels)
ax.legend()

ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)

fig.tight_layout()

plt.show()

Hope this will help someone too

Jj Encrypt
  • 11
  • 5