I am trying to create a graph of value ranges so that they can be compared to a unique range (represented by a gray rectangle in the graph). I got the graph to work just like I wanted to it but I cannot effectively change the line weight of the error bars that I am using to represent the value ranges. The code it below with example figures.
### Graph with default line weights
ggplot(data=droplevels(wght2[which(wght2$Zone!="Oahu"),]), aes(x=wght2$num[wght2$Zone!="Oahu"], y=(wght2[which(wght2$Zone!="Oahu"),4]+wght2[which(wght2$Zone!="Oahu"),4+3])/2,
group= wght2[which(wght2$Zone!="Oahu"),2], color= wght2[which(wght2$Zone!="Oahu"),2])) +
geom_errorbar(aes(ymin=wght2[which(wght2$Zone!="Oahu"),4], ymax=wght2[which(wght2$Zone!="Oahu"),4+3], width=0.3, color=wght2[which(wght2$Zone!="Oahu"),2])) +
geom_rect(ymin=wght2[8,4], ymax=wght2[8,4+3], xmin=0.5, xmax=6+0.5, fill="gray25", linetype=0, alpha=0.07)+
scale_color_manual(values=c("forestgreen","deepskyblue3","gold"))+
scale_x_continuous(labels=levels(wght2$Zone), breaks=c(1,2,3.5,5.5))+
labs(x="Zone",y=measure3[4]) +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.text = element_text(size = 16),
legend.title = element_text(size=16),
axis.text = element_text(size = 16,colour="black"),
axis.title = element_text(size = 18)) +
theme(legend.position="topright")
### My attempt to change line weights
ggplot(data=droplevels(wght2[which(wght2$Zone!="Oahu"),]), aes(x=wght2$num[wght2$Zone!="Oahu"], y=(wght2[which(wght2$Zone!="Oahu"),4]+wght2[which(wght2$Zone!="Oahu"),4+3])/2,
group= wght2[which(wght2$Zone!="Oahu"),2], color= wght2[which(wght2$Zone!="Oahu"),2])) +
geom_errorbar(aes(ymin=wght2[which(wght2$Zone!="Oahu"),4], ymax=wght2[which(wght2$Zone!="Oahu"),4+3], width=0.3, size=0.5, color=wght2[which(wght2$Zone!="Oahu"),2])) +
geom_rect(ymin=wght2[8,4], ymax=wght2[8,4+3], xmin=0.5, xmax=6+0.5, fill="gray25", linetype=0, alpha=0.07)+
scale_color_manual(values=c("forestgreen","deepskyblue3","gold"))+
scale_x_continuous(labels=levels(wght2$Zone), breaks=c(1,2,3.5,5.5))+
labs(x="Zone",y=measure3[4]) +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
legend.text = element_text(size = 16),
legend.title = element_text(size=16),
axis.text = element_text(size = 16,colour="black"),
axis.title = element_text(size = 18)) +
theme(legend.position="topright")
As you can see from my code when I include the 'size' argument in the 'aes' function of geom_errorbar, the line weights become huge even though I set it at the default which is 0.5.
Any advice on how to change the line weights in geom_errorbar would be much appreciated. I know I could just draw each line in with geom_segment but feel like using geom_errorbar should work and want to know why it is not. Thanks!