本文介绍了ggplot躲过了barplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想从以下数据框中创建一个barplot: $ (2.4,3,3,3.16,2.5,2.5,3,4.5) sds ,1.0,1.1,2.1,0.7,2.8,0.7)个队个比例 data 在此之前,它运行良好,我得到了一张照片,其中蓝色和红色旁边标有偏差。 pre $ lt; code> graph< - ggplot(data = datas,aes(scales,y = means)) graph + geom_bar(aes(fill =球队),stat =身份,position =dodge)+ no_margins + geom_errorbar(aes(ymin =平均值= sds,ymax =平均值+ sds,宽度= 0.2),position = position_dodge (宽度= 0.90))+ coord_flip() 安装最新版本的R (2.15.1),我得到的只是一个文件,其中4个栏显示为蓝色而不是躲闪(彼此旁边) 有没有人有一个想法,其中的变化(颜色,闪避)从哪里来? 我花了好几个小时的结果,所以非常感谢您的任何建议! / b>我不确定它为什么不能正常工作,但是这里有一个版本。 graph ggplot(data = datas,aes(scales,y = means,group = teams))+ geom_bar(aes(fill = teams),stat =identity, position =dodge)+ geom_errorbar(aes(ymin =平均值= sds,ymax =平均值+ sds,宽度= 0.2), position = position_dodge(width = 0.90))+ coord_flip() 我把 group = teams geom_bar 中有一个 fill = teams 。 I'm desperately looking for a solution for this problem:I want to create a barplot from the following dataframe:means <- c(2.4,3,3,3.16,2.5,2.5,3,4.5)sds <- c(1.0,1.2,1.0,1.1,2.1,0.7,2.8,0.7)teams <- c(1,1,1,1,2,2,2,2)scales <- c(1,2,3,4,1,2,3,4)datas <- data.frame(teams, scales, means, sds)Before, it worked well and I got a picture which where beside each other in blue and red with standard deviations.graph <- ggplot(data=datas, aes(scales, y=means))graph + geom_bar(aes(fill=teams), stat="identity", position="dodge") + no_margins + geom_errorbar(aes(ymin= means - sds, ymax = means + sds, width=0.2), position=position_dodge(width=0.90)) + coord_flip() After installing the latest version of R (2.15.1), all I get is a file, where the 4 bars appear in blue and not dodged (beside each other)Does anyone have an idea, where the change (colour, dodge) came from? I have spent hours for results, so thank you very much for any recommendations! 解决方案 I'm not sure why it isn't working right, but here is a version that does.graph <- ggplot(data=datas, aes(scales, y=means, group=teams)) + geom_bar(aes(fill=teams), stat="identity", position="dodge") + geom_errorbar(aes(ymin= means - sds, ymax = means + sds, width=0.2), position=position_dodge(width=0.90)) + coord_flip()I put group=teams into the aesthetics; it shouldn't be necessary because you have a fill=teams in geom_bar. 这篇关于ggplot躲过了barplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 22:21