Fügen Sie den Wert über jede Balken mit Funktion mit Funktion hinzu

female_b1 = ax.bar(indx_b1 + width_b1/2, female_sum, width_b1, color = '#ff9999', label = 'Female')

def inset_bar_chart_labels(bars):
    for bar in bars:
        bar_height = bar.get_height()

        ax.annotate('{0:.0f}'.format(bar_height),
                xy = (bar.get_x() + bar.get_width()/2, bar_height),
                xytext = (0,3), textcoords = 'offset points', ha = 'center', va = 'bottom')
                
inset_bar_chart_labels(female_b1)
Chunxiao Wang