I can't seem to find a way to get the text labels on this (dodged) geom_col
to line up according to their respective columns.
I have tried numerous suggestions solutions on SO and other sites, and this is the closest I could get:
How do I fix this?
Code:
ggplot(leads[leads$key_as_string <= max(leads$key_as_string) - 1, ], aes(fill = type)) +
geom_col(aes(x = key_as_string, y = doc_count),
colour = "black",
position = position_dodge(1)) +
scale_y_continuous(limits = c(0, max(leads$doc_count))) +
geom_text(aes(x = key_as_string, y = doc_count, label = doc_count, group = key_as_string),
hjust = 0.5,
vjust = -0.5,
size = 3,
colour = "black",
position = position_dodge(1)) +
theme(panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
axis.text = element_text(colour = "black"))