ループを使用して、ここで作成したような一連の反転棒グラフを作成します。それらを作成した後、大幅に異なるバーに異なる色を付けたいと思います。したがって、プロットを作成した後にバーの色を変更する必要があります。を使用してみscale_fill_manual
ましたが、これは効果がありませんでした。1つのグラフのデータがどのように構造化されているか、および私のスクリプトは次のとおりです
Station=rep("Station",5)
Slice=-1*(0:4)
mean.TD=c(344,1129,355,1349,674)
se.TD=c(114,438,121,390,14)
data115=data.frame(Station, Slice,mean.TD,se.TD)
data115
FC115=ggplot(data115, aes(x=Slice, y=mean.TD )) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymin=mean.TD-se.TD, ymax=mean.TD+se.TD),
width=3
position=position_dodge(.9))+
theme_bw()+
ylab(expression("nematode densities (ind. 10cm"^-2*")")) +
xlab("Depth (cm)")+
coord_flip() +
scale_x_continuous(breaks = -4:0, labels=c("4-5","3-4","2-3","1-2","0-1"))
FC115