library(tidyverse)
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::percent()
上面而不是scales::percent_format(accuracy = 5L)
我的百分比标签中有小数位,这是我不想要的。
问题是——5L有什么作用在我上面的例子中?为什么需要使用整数 5L 而不是 5?为什么 6L 会将最高 y 值从 40% 更改为 42%?这实在是太奇怪了。
逗号后 5 位数字
library(ggplot2)
library(tidyverse)
mtcars %>%
count(cyl) %>%
mutate(prop = n / sum(n)) %>%
ggplot(aes(x = cyl, y = prop)) +
geom_point() +
scale_y_continuous(labels = scales::percent_format(accuracy=.00001))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)