如何在条形图中将Y轴数字更改为百分比? [英] How can I change the Y-axis figures into percentages in a barplot?

查看:578
本文介绍了如何在条形图中将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))

(自ggplot2的2.2.1版本以来,该命令labels = percent已过时)

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

这篇关于如何在条形图中将Y轴数字更改为百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆