View source: R/ggplot_helpers.R
bar_just | R Documentation |
Calculate hjust/vjust to align labels to the end of bars in ggplot2
bar_just(x, pivot = 0.5)
x |
numeric |
pivot |
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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.