I plotted columns with the ggplot2 package and the geom_col() function. I put a label at the top of each column with the respective values with the geom_label() function. Inside the geom_label() function I modified the text size (size = 3) and label position (vjust = -1), but the result showed the label in the desired position but with the text off-center.
How can I fix this issue?
library(ggplot2)
Factor <- c('A', 'B')
Y <- c(5, 10)
DF <- data.frame(Factor, Y)
ggplot(data = DF,
aes(x = Factor,
y = Y)) +
geom_col() +
geom_label(aes(label = Y),
vjust = -1,
size = 3) +
scale_y_continuous(limits = c(0, 15))


