I want to produce a bar plot, similar to this MWE:
library(tidyverse)
library(ggplot2)
mtcars %>%
mutate(mpg=mpg/1000) %>%
ggplot(aes(x=cyl, y=mpg)) +
geom_bar(stat="identity") +
scale_y_continuous(labels = scales::percent)
What I get is the following (keep in mind that it is nonsense, but serves illustration purposes): Now, I want the decimals replaced from the percentages on the y-axis ("30%" instead of "30.0%"). What can I do?
I have found a similar question here, but couldn't make the function NRPercent
does not work (and can't comment there).
With the new version of scales
you can use:
scale_y_continuous(labels = scales::percent_format(accuracy = 1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With