scales::percent_format
和它的accuracy
参数(“四舍五入的数字”)。{{scales::percent_format}} {{accuracy}}mtcars %>%
count(cyl) %>%
mutate(prop = n / sum(n)) %>%
ggplot(aes(x = cyl, y = prop)) +
geom_point() +
scale_y_continuous(labels = scales::percent_format(accuracy = 5L))
更新一下,scales::label_percent(accuracy = 1L)
将四舍五入到整数,scales::label_percent(accuracy = 0.1L)
将四舍五入到小数点后一位,以此类推。