|||
## 构建数据
dat <- data.frame(var = c("A","B","C"), mean =c (0.25,0.45,0.65), sd = c(0.1,0.15,0.2))
> dat
var mean sd
1 A 0.25 0.10
2 B 0.45 0.15
3 C 0.65 0.20
##
library(ggplot2)
f <- ggplot(dat,aes(x=var, y=mean)) +
geom_bar(stat = "identity", position=position_dodge(), width=0.6,
color="red", fill=c("white","grey","black")) + ## 柱状图线条颜色和填充色
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), width=0.2,
color="blue", ## 误差线颜色
position=position_dodge(0.6))
## 更改主图
f + theme_bw()
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-10-20 02:00
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社