bar_just: Calculate hjust/vjust to align labels to the end of bars in...

View source: R/ggplot_helpers.R

bar_justR Documentation

Calculate hjust/vjust to align labels to the end of bars in ggplot2

Description

Calculate hjust/vjust to align labels to the end of bars in ggplot2

Usage

bar_just(x, pivot = 0.5)

Arguments

x

numeric

pivot

numeric

Value

hjust or vjust

Examples

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)))

edalfon/efun documentation built on June 23, 2024, 4:17 a.m.