How can I change the Y-axis figures into percentages in a barplot?

前端 未结 4 1548
清歌不尽
清歌不尽 2020-11-28 21:50

How can we change y axis to percent like the figure? I can change y axis range but I can\'t make it to percent. \"enter

4条回答
  •  执笔经年
    2020-11-28 22:04

    Use:

    + scale_y_continuous(labels = scales::percent)
    

    Or, to specify formatting parameters for the percent:

    + scale_y_continuous(labels = scales::percent_format(accuracy = 1))
    

    (the command labels = percent is obsolete since version 2.2.1 of ggplot2)

提交回复
热议问题