如何将 Y 轴数字更改为条形图中的百分比? [英] How can I change the Y-axis figures into percentages in a barplot?
本文介绍了如何将 Y 轴数字更改为条形图中的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何像图中那样将 y 轴更改为百分比?我可以更改 y 轴范围,但无法达到百分比.
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.
推荐答案
使用:
+ scale_y_continuous(labels = scales::percent)
或者,指定百分比的格式参数:
Or, to specify formatting parameters for the percent:
+ scale_y_continuous(labels = scales::percent_format(accuracy = 1))
(命令 labels = percent
自 ggplot2 2.2.1 版起已过时)
(the command labels = percent
is obsolete since version 2.2.1 of ggplot2)
这篇关于如何将 Y 轴数字更改为条形图中的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文