I am trying to position my data label inside the ggplot horizontal bar as the label gets cut off when placed at end of the bar. I have tried various different methods such as adjusting hjust position but the label disappears under the bar, I have even tried to increase x axis using xlim/ scale_x_continuous to allow the label to be fully viewed but so far keep failing.
library(tidyverse)
library(ggplot2)
mydf <- data.frame( Category = c("Approved transactions"),
Nov_21=c(11028),
Dec_21=c(31455),
Jan_22=c(44480))
mydf %>%
gather(Month, Total, -Category) %>%
mutate(Month = reorder(Month, row_number())) %>%
mutate(Category = reorder(Category, row_number())) %>%
ggplot(aes(Month, Total, fill = Month, group = Category)) +
geom_text(aes(label=Total), position=position_dodge(width=0.9), hjust= 0.25) +
geom_bar(stat = "identity", position = "dodge", width=0.5, fill="light blue") +
coord_flip() +
labs(x = "", y = "", title = "Approved Counter Transactions", subtitle = "3 Month View", legend=FALSE) +
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.border = element_blank(),
plot.title = element_text(hjust = 0),
axis.text.x = element_text(size = 10, face = "bold"),
axis.text.y = element_text(size = 10, face = "bold"),
legend.position = "none")

