I changed the y axis to percentages using the following code:
require(ggplot2)
require(scales)
p <- ggplot(mydataf, aes(x = foo)) +
geom_bar(aes(y = (..count..)/sum(..count..))) +
scale_y_continuous(labels = percent_format())
That helped, but the label is now: (count)/sum(count)
and I want it to be: percentage
Any suggestion? Thanks.
library(scales)
p + scale_y_continuous(labels=percent)
That should do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.