Hello everyone,
I have tried to change the number size (fontsize) shown on bar plots by using bar_label. But I always get the error ‘AxesSubplot’ object has no attribute ‘bar_label’. I have updated my package matplotlib but it doesn’t solve my problem. If anyone knows how to solve it or any idea please let me know.
Here is my code:
labels = ['Day1', 'Day2', 'Day3', 'Day4', 'Day5', 'Day6', 'Day7']
x = np.arange(len(labels))
width = 0.35 # the width of the bars
fig5, ax = plt.subplots()
rects1 = ax.bar(x - width / 2, round(self.EMS.df_aut['Autarchy'], 2), width, label='Autarchy')
rects2 = ax.bar(x + width / 2, round(self.EMS.df_aut['Self_consumption'], 2), width,
label='Self_consumption')
ax.set_ylabel('Percentage')
ax.set_title('Autarchy and Self_consumption Rate of {} with EMS run{}'.format(self.name, run_type))
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.bar_label(rects1,fontsize=6)
ax.bar_label(rects2, fontsize=6)
Thanks