title: How to display percentage label in histogram plot in Python
body: <p>I managed to create a plot that shows the number of records per class label for each age in my Pandas dataframe. But I would also like to see a percentage label for the "non functional" class in each age group.</p>
  
  <p>The Python code for the graph is</p>
  
  <pre><code>train['age_wpt'] = train.date_recorded.str.split('-').str.get(0).apply(int) - train.construction_year
  
  figure = plt.figure(figsize=(15,8))
  plt.hist([
          train[(train.status_group=='functional') &amp; (train.age_wpt &lt; 60.0) &amp; (train.age_wpt &gt;= 0.0)]['age_wpt'],
          train[(train.status_group=='non functional') &amp; (train.age_wpt &lt; 60.0) &amp; (train.age_wpt &gt;= 0.0)]['age_wpt'],
          train[(train.status_group=='functional needs repair') &amp; (train.age_wpt &lt; 60.0) &amp; (train.age_wpt &gt;= 0.0)]['age_wpt']
          ], 
           stacked=True, color = ['b','r','y'],
           bins = 30,label = ['functional','non functional', 'functional needs repair'])
  plt.xlabel('Age')
  plt.ylabel('Number of records')
  plt.legend()
  </code></pre>
  
  <p>This results in the following graph
  <a href="https://i.stack.imgur.com/LYaQ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LYaQ4.png" alt="enter image description here"></a></p>