title: Stacked Bar Graph Labels with ggplot2
body: <p>I am trying to graph the following data:</p>
  
  <pre><code>to_graph &lt;- structure(list(Teacher = c("BS", "BS", "FA"
  ), Level = structure(c(2L, 1L, 1L), .Label = c("BE", "AE", "ME", 
  "EE"), class = "factor"), Count = c(2L, 25L, 28L)), .Names = c("Teacher", 
  "Level", "Count"), row.names = c(NA, 3L), class = "data.frame")
  </code></pre>
  
  <p>and want to add labels in the middle of each piece of the bars that are the <em>percentage</em> for that piece. Based on <a href="https://stackoverflow.com/questions/6644997/showing-data-values-on-stacked-bar-chart-in-ggplot2">this post</a>, I came up with:</p>
  
  <pre><code>ggplot(data=to_graph, aes(x=Teacher, y=Count, fill=Level), ordered=TRUE) + 
      geom_bar(aes(fill = Level), position = 'fill') + 
      opts(axis.text.x=theme_text(angle=45)) + 
      scale_y_continuous("",formatter="percent") + 
      opts(title = "Score Distribution") + 
      scale_fill_manual(values = c("#FF0000", "#FFFF00","#00CC00", "#0000FF")) + 
      geom_text(aes(label = Count), size = 3, hjust = 0.5, vjust = 3, position = "stack")
  </code></pre>
  
  <p>But it</p>
  
  <ol>
  <li>Doesn't have <em>any</em> effect on the graph</li>
  <li>Probably doesn't display the percentage if it did (although I'm not entirely sure of this point)</li>
  </ol>
  
  <p>Any help is greatly appreciated. Thanks!</p>