Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 分组置信区间柱状图_R_Ggplot2 - Fatal编程技术网

R 分组置信区间柱状图

R 分组置信区间柱状图,r,ggplot2,R,Ggplot2,a试试这个 limits <- aes(ymax = value + se, ymin=value - se) p<-ggplot(data = a, aes(x = X1, y =value))+ geom_bar(aes(fill=X2),position = "dodge") + scale_x_discrete(name="")+ scale_fill_manual(values=c("grey80","black","red"))+

a试试这个

limits <- aes(ymax = value + se, ymin=value - se)
 p<-ggplot(data = a, aes(x = X1, y =value))+   
    geom_bar(aes(fill=X2),position = "dodge") +    
    scale_x_discrete(name="")+
    scale_fill_manual(values=c("grey80","black","red"))+
    scale_y_continuous(name="%")+   
    theme(axis.text.y = element_text(face='bold'),
          legend.position ="top",
          legend.title=element_blank())+   
     coord_flip()
p + geom_linerange(limits)

p您是否错过了包含限制?如果我知道你想在每个栏上加一行,谢谢。我已经修改了代码,真的很抱歉,我发布得太快了。在我试图匿名化数据的过程中,我实际上错误地标记了变量!我现在已经修改了数据集并重新运行代码。你应该能看到我现在的问题是什么。如果我浪费了你的时间,我真的很抱歉。要给你的数据提供一个可复制的样本,请使用dput,键入dput(a)并回答你的问题。再次感谢你是明星。非常感谢。和scale_y_continuous(name=“%”,labels=function(x)x*100)应如我所述修改比例(参见)
limits <- aes(ymax = value + se, ymin=value - se)
 p<-ggplot(data = a, aes(x = X1, y =value))+   
    geom_bar(aes(fill=X2),position = "dodge") +    
    scale_x_discrete(name="")+
    scale_fill_manual(values=c("grey80","black","red"))+
    scale_y_continuous(name="%")+   
    theme(axis.text.y = element_text(face='bold'),
          legend.position ="top",
          legend.title=element_blank())+   
     coord_flip()
p + geom_linerange(limits)
p<-ggplot(data = df, aes(x = X1, y =value,fill= X2))+   
    geom_bar(position=position_dodge()) +
    geom_errorbar(aes(ymax = value + 2* se, ymin=value,colour = X2),position=position_dodge(.9))



p <- p + scale_x_discrete(name="")+
   scale_fill_manual(values=c("grey80","black","red"))+
   scale_y_continuous(name="%")+   
   theme(axis.text.y = element_text(face='bold'),
         legend.position ="top",
         legend.title=element_blank())+   
   coord_flip()