I'd like to create a stacked bar chart in ggplot2 with the data labels centered over the filled area that they relate to. The code I've tried has the labels in the reverse order that they should be in. here is a sample of code:
data_rep <- data.frame(Task.Number = c('5.004','5.004','5.01','5.01','5.04','5.04'),
Within_SLA = rep(c('No','Yes'),3),
Perc_SLA = c(4.8,95.2,1,99,9.6,90.4))
ggplot(data_rep, aes(x=Task.Number,y=Perc_SLA)) +
geom_bar(aes(fill=Within_SLA),stat="identity",position="stack") +
geom_text(aes(label=Perc_SLA), size = 3) +
scale_fill_discrete(name = "Within SLA") +
coord_flip()
This is what I'm getting: