scales
scales copied to clipboard
label_percent in geom_label
Should it be possible to switch percent() for label_percent() inside geom_label() per the examples below?
library(tidyverse)
library(scales, warn.conflicts = FALSE)
tribble(~name, ~pct,
"A", 0.1,
"B", 0.2) |>
ggplot(aes(name, pct)) +
geom_label(aes(label = percent(pct))) + # using percent
scale_y_continuous(labels = label_percent())

tribble(~name, ~pct,
"A", 0.1,
"B", 0.2) |>
ggplot(aes(name, pct)) +
geom_label(aes(label = label_percent(pct))) + # using label_percent
scale_y_continuous(labels = label_percent())
#> Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
#> Error in `f()`:
#> ! Aesthetics must be valid data columns. Problematic aesthetic(s): label = label_percent(pct).
#> Did you mistype the name of a data column or forget to add after_stat()?

Created on 2022-04-19 by the reprex package (v2.0.1)