title: ggplot histogram with % and percentage *labels*
body: <p>I want to use ggplot to make a histogram using percentages. I found <strong><a href="https://stackoverflow.com/questions/3695497/ggplot-showing-instead-of-counts-in-charts-of-categorical-variables">this answer</a></strong> that gets me part of the way there.</p>
  
  <p>However, I also want to place a <strong>label at the top of each histogram bar</strong> showing the actual percentage.</p>
  
  <p>Here is my code and a link to the output:</p>
  
  <pre><code>p &lt;- ggplot(mtcars, aes(x = hp)) +  
          geom_bar(aes(y = (..count..)/sum(..count..)), binwidth = 25) + 
          ## scale_y_continuous(labels = percent_format()) #version 3.0.9
          scale_y_continuous(labels = percent) #version 3.1.0
  p &lt;- p + stat_bin(aes(label=round((..count..)/sum(..count..),2)), geom="text", size=4)
  plot(p)
  </code></pre>
  
  <p>Here is the output: <img src="https://i.stack.imgur.com/W97IK.png" alt="image"></p>
  
  <p>Unfortunately, you can see that the data labels are placed at the non-percentage locations and the bars are "smushed" down.</p>
  
  <p>Is there a way to change the stat_bin parameters so that the text labels actually show up inside or immediately on top of the percentage bars (so that my bars aren't smushed)?</p>
  
  <p>Thank you!</p>