将y轴转换为百分比ggplot

将y轴转换为百分比ggplot

本文介绍了将y轴转换为百分比ggplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我已经使用堆叠条形图(与coord_flip)来比较前后测试对照组和治疗组的分布(这是我正在玩的几种技术之一)。这里是情节: 这里是代码(对不起,没有数据集是不可重现的。如果这是一个问题,我会组成一个可重复的数据集,因为我不能共享真实数据): m4 m5 facet_grid(time_type)+ scale_fill_grey() 如何将y轴(实际上是在底部会费到 coord_flip )上更改为百分比,以便每条线都相等长度?所以我希望能够成为百分之百。我需要某种转变,我敢打赌,ggplot已经或可以很容易地创建并应用一些方法。只需 position_fill ,方法是设置 + geom_bar(position =fill) I have used a stacked bar chart (with coord_flip) to try to compare distributions (this is one a several techniques I'm playing with) for a control and treatment group for pre and post test. Here is the plot:and here is the code (Sorry it's not reproducible with no data set. If this is a problem I'll make up a reproducible data set as I can't share the real data):m4 <- ggplot(data=v, aes(x=trt, fill=value))m5 <- m4 + geom_bar() + coord_flip() + facet_grid(time~type) + scale_fill_grey()How can I change the y axis (which is actually on the bottom dues to coord_flip) to percents so every bar is equal in length? So I want counts to become percents. I need some sort of transformation that I'm betting ggplot has or could easily be created and applied some how. 解决方案 You probably just want position_fill, by setting,+ geom_bar(position = "fill") 这篇关于将y轴转换为百分比ggplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 02:00