我正在尝试使用下图进行两项操作 1 - 制作上限错误栏 2 - 加粗误差条
这是我使用的代码集
data$rotation[data$Rot.trt %in% c("C2", "S2")]<-"TwoYear"
data$rotation[data$Rot.trt %in% c("C3", "S3", "O3")]<-"ThreeYear"
data$rotation[data$Rot.trt %in% c("C4", "S4", "O4", "A4")]<-"FourYear"
ggplot(data, aes(x=Rot.Herb.label, y=kg.ha, fill=Crop))+
geom_boxplot()+
facet_grid(~rotation, scales = "free_x", space="free_x")+
scale_fill_brewer(palette = "Paired")+
theme_bw() +
theme(panel.grid.major=element_blank())+
ggtitle("Weed biomass by plot")+
theme(plot.title = element_text(size=30, face="bold", vjust=2))+
xlab("Treatment (L = Low herbicide regime, C = Conventional herbicide regime)")+
theme(axis.text.x = element_text(size = 16, angle = 90, hjust = 1),axis.title=element_text(size=16,face="bold"))+
ylab("Weed dry weight (kg/ha)")+
theme(axis.text.y = element_text(size = 16))
正如this question所述,我尝试在geom_boxplot
行之前添加此部分,但它没有帮助。
geom_bar(width= .1, position="dodge", color="black", stat="identity")+
geom_errorbar(aes(ymin=kg.ha-ci, ymax=kg.ha+ci),
width=.2,
position=position_dodge(.9))
这是data
> str(data)
'data.frame': 72 obs. of 69 variables:
$ Date : Factor w/ 10 levels "10-Sep-14","12-Sep-14",..: 10 10 10 10 10 10 1 1 1 1 ...
$ Plot : int 11 11 13 13 18 18 23 23 24 24 ...
$ Rep : Factor w/ 4 levels "1rep","2rep",..: 1 1 1 1 1 1 2 2 2 2 ...
$ Side : Factor w/ 2 levels "E","W": 2 1 2 1 2 1 2 1 2 1 ...
$ Crop : Factor w/ 4 levels "alfalfa","corn",..: 2 2 2 2 2 2 2 2 2 2 ...
$ Rot : Factor w/ 3 levels "2rot","3rot",..: 2 2 1 1 3 3 2 2 1 1 ...
$ Rot.Herb : Factor w/ 18 levels "A4conv","A4low",..: 5 6 4 3 8 7 5 6 4 3 ...
$ Rot.trt : Factor w/ 9 levels "A4","C2","C3",..: 3 3 2 2 4 4 3 3 2 2 ...
$ Herb.trt : Factor w/ 2 levels "conv","low": 1 2 2 1 2 1 1 2 2 1 ...
$ DIGSANo : int 0 0 0 0 2 0 0 0 0 0 ...
$ DIGSAWt : num 0 0 0 0 1.3 0 0 0 0 0 ...
$ SETFANo : int 1 3 1 0 2 0 0 2 0 0 ...
$ SETFAWt : num 0.1 61 1.5 0 14 0 0 4.1 0 0 ...
$ SETLUNo : int 0 0 0 0 1 0 0 0 0 0 ...
$ SETLUWt : num 0 0 0 0 0.1 0 0 0 0 0 ...
$ PANCANo : int 0 0 0 0 0 0 0 0 0 0 ...
$ PANCAWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ ECHCGNo : int 0 0 0 0 6 0 0 0 0 0 ...
$ ECHCGWt : num 0 0 0 0 21.7 0 0 0 0 0 ...
$ ERBVINo : int 0 0 0 0 0 0 0 0 0 0 ...
$ ERBVIWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ CYPESNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ CYPESWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ AMATANo : int 0 2 8 4 2 1 1 0 1 3 ...
$ AMATAWt : num 0 25.5 8.3 0.1 1.2 0 0 0 0.03 1.57 ...
$ CHEALNo : int 6 44 0 0 0 0 0 15 2 0 ...
$ CHEALWt : num 0.1 208.1 0 0 0 ...
$ SOLPTNo : int 0 0 0 0 0 11 1 3 18 4 ...
$ SOLPTWt : num 0 0 0 0 0 0.4 0.08 0.3 5.81 0.17 ...
$ PHYSUNo : int 0 5 2 6 2 1 0 0 0 0 ...
$ PHYSUWt : num 0 2.1 13.9 0 0.1 0 0 0 0 0 ...
$ POLCCNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ POLCCWt : int 0 0 0 0 0 0 0 0 0 0 ...
$ POLPYNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ POLPYWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ ABUTHNo : int 4 0 2 0 6 0 1 0 0 0 ...
$ ABUTHWt : num 0.2 0 0.1 0 3.1 0 0.07 0 0 0 ...
$ TAROFNo : int 6 4 0 21 6 3 6 7 17 33 ...
$ TAROFWt : num 0.1 0 0 0 0.1 0 0.07 0.23 0.18 0.51 ...
$ EPHHTNo : int 0 0 0 1 2 0 0 0 5 0 ...
$ EPHHTWt : num 0 0 0 0 0.1 0 0 0 0.13 0 ...
$ CIRARNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ CIRARWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ SONARNo : int 0 0 0 0 0 0 0 0 1 0 ...
$ SONARWt : num 0 0 0 0 0 0 0 0 0.1 0 ...
$ MORALNo : int 0 5 0 0 0 1 0 0 0 0 ...
$ MORALWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ OXASTNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ OXASTWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ POLLANo : int 0 0 0 0 0 0 0 0 0 0 ...
$ POLLAWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ ASCSYNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ ASCSYWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ POLAVNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ POLAVWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ PLAMANo : int 0 0 0 0 0 0 0 0 0 0 ...
$ PLAMAWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ UnknowndicotNo : int 0 0 0 0 0 0 0 0 0 0 ...
$ UnknowndicotWt : num 0 0 0 0 0 0 0 0 0 0 ...
$ UnknownmonocotNo: int 0 0 0 0 0 0 0 0 0 0 ...
$ UnknownmonocotWt: num 0 0 0 0 0 0 0 0 0 0 ...
$ TOTALNo : int 17 63 13 32 29 17 9 27 44 40 ...
$ TOTALWt : num 0.5 296.7 23.8 0.1 41.7 ...
$ samplearea.m.2. : num 18.5 18.5 18.5 18.5 18.5 ...
$ g.m.2 : num 0.03 16.01 1.28 0.01 2.25 ...
$ kg.ha : num 0.27 160.1 12.84 0.05 22.5 ...
$ lb.acre : num 0.24 142.97 11.47 0.05 20.09 ...
$ rotation : chr "Three Year" "Three Year" "Two Year" "Two Year" ...
$ Rot.Herb.label : Factor w/ 8 levels "Alfalfa C","Alfalfa L",..: 3 4 4 3 4 3 3 4 4 3 ...