代码
library(reshape2)
library(ggplot2)
mydata<-read.csv("input_total10.13.csv", header=T)
data<-melt(mydata)
head(data)
ebtop<-function(x){
return(mean(x)+sd(x)/sqrt(length(x)))
}
ebbottom<-function(x){
return(mean(x)-sd(x)/sqrt(length(x)))
}
ggplot(data=data,aes(x=data$group,y=value,fill=data$variable))+
stat_summary(geom = "bar",fun = "mean",
position = position_dodge(0.9))+
stat_summary(geom = "errorbar",
fun.min = ebbottom,
fun.max = ebtop,
position = position_dodge(0.9),
width=0.2)+
theme_classic()+
theme(panel.grid = element_blank())+
scale_fill_manual(values = c("#81B29A","#F2CC8F","#3D405B","#E07A5F"),
name="TTL")+
labs(x="XXXXX",y="YYYYY") ##设置颜色和坐标轴
数据:
![](https://img.haomeiwen.com/i27031781/6f16b0e09bb63dcf.png)
结果图:
![](https://img.haomeiwen.com/i27031781/eafb6e2d49b46f1a.png)
代码来源于:https://cloud.tencent.com/developer/article/1917844
网友评论