Bar charts with percentage labels but counts on the y axis

Bar charts and histograms are easily to understand. I often write for non-specialist audiences so I tend to use them a lot. People like percentages too, so a bar chart with counts on the y axis but percentage labels is a useful thing to be able to produce.

But how to do this in our graphics package of choice, ggplot? ggplot makes histograms by doing a stat transformation, stat_bin. Sure, this is helpful because you don’t have to prepare your data so much first, it will work out the bins and bin size for you. But it makes it correspondingly harder to customise the plot to get what you want, - concretely, in this case, to get percentage labels.

This is the cleanest way I could find - if you have a better idea, please post a comment!

geom_bar(aes(y = (..count..)),fill="orange")+
geom_text(aes(y = (..count..),label =   ifelse((..count..)==0,"",scales::percent((..count..)/sum(..count..)))), stat="bin",colour="darkgreen") 

Up next GANTT software I quite often get asked (and ask myself) what is the best GANTT software for basic use. Recently we have been comparing a few solutions so here are Measuring resilience This article is work in progress! Feel free to add a comment. There should be a pdf at this link. After the terrible earthquake in Haiti in 2010,
Latest posts Causal Map intro Causal Mapping - an earlier guide The walk to school in Sarajevo Glitches Draft blog post for AEA365 Theory Maker! Inventory & analysis of small conservation grants, C&W Africa - Powell & Mesbach! Lots of charts! Answering the “why” question: piecing together multiple pieces of causal information rbind.fill for 1-dimensional tables in r yED graph editor Examples of trivial graph format Using attr labels for ggplot An evaluation puzzle: “Talent show” An evaluation puzzle: “Mobile first” An evaluation puzzle: “Many hands” An evaluation puzzle: Loaves and fishes An evaluation puzzle: “Freak weather” An evaluation puzzle: “Billionaire” Publications Using Dropbox for syncing Shiny app data on Amazon EC2 Progress on the Causal Map app Articles and presentations related to Causal Maps and Theorymaker Better ways to present country-level data on a world map: equal-area cartograms A starter kit for reproducible research with R A reproducible workflow for evaluation reports Welcome to the Wiggle Room Realtime comments on a Theory of Change Responses to open questions shown as tooltips in a chart A panel on visualising Theories of Change for EES 2018? Peer mentoring for evaluators How do you explain reproducible research to clients?