Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Add value on top of each bar using function

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)
 
PREVIOUS NEXT
Tagged: #Add #top #bar #function
ADD COMMENT
Topic
Name
4+8 =