R/ggplot_helpers.R
bar_just.Rd
Calculate hjust/vjust to align labels to the end of bars in ggplot2
bar_just(x, pivot = 0.5)
numeric
hjust or vjust
library(ggplot2) mtcars |> tibble::rownames_to_column() |> ggplot(aes(y = reorder(rowname, mpg), x = mpg, label = mpg)) + geom_col(fill = "deepskyblue") + geom_text(aes(hjust = bar_just(mpg)))