Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Add label to histogram

n, edges, patches = plt.hist(response_bachelor['Bachelor_GradYear'], bins = bins, 
                             color='#f0ae5d', edgecolor='w', label = 'No.of Responses') 

#add number of responses on top of each bin
for rect, label in zip(patches, n):
  height = rect.get_height()                   
  ax.text(rect.get_x() + rect.get_width()/2, height + 0.01, int(label), ha='center', va='bottom') 
 
PREVIOUS NEXT
Tagged: #Add #label #histogram
ADD COMMENT
Topic
Name
4+2 =