0

I have a chart (it started out as a histogram but I changed it to a bar chart so that I could use percentages more easily):

enter image description here

This is the code for the chart:

ggplot(df, aes(as.Date(callclosed), y = (..count..)/sum(..count..))) +
      geom_bar(fill = "skyblue1",
               colour = "black") +
      scale_y_continuous(labels = scales::percent, limits = c(0, 0.06)) +
      scale_x_date(date_breaks = "1 day", date_labels = "%d-%b-%y") +
      theme(axis.text.x = element_text(angle = 90))

How can I add labels to the top of each bar that shows the associated percentage?

Mus
  • 7,290
  • 24
  • 86
  • 130
  • 2
    Try this `geom_text(aes( label = format(100*..density.., digits=2, drop0trailing=TRUE), y= ..density.. ), stat= "bin", vjust = -.5) +` OR `geom_text(aes( label = scales::percent(..prop..), y= ..prop.. ), stat= "count", vjust = -.5)` – Rushabh Patel Apr 25 '19 at 14:42
  • In above dup question, see [@SamFirke's answer](https://stackoverflow.com/a/35067032/1422451). – Parfait Apr 25 '19 at 14:50

0 Answers0