I have been staring at this same graph for almost a week now and can’t seem to find a way to make it do the things it needs to do. My usual way to do this would be a geom_linerange coupled with geom_point. I started with that and then started running into an issue with position dodge where the points and linerange never would line up correctly coupled with the position dodge being all over the place with geom_path connecting the means.
I have restarted trying to graph this quite a few times and keep coming back to this. The legend still shows the fill for year as black rather than suggested color, and the geom_path in plot 2 is a nightmare. Suggestions on things to try? This setup is how I have been trying to do all of the graphs for this section (forage and fecal counts by patch time and ESD). The problems seem to follow from one graph to the other. Hopefully the solution will too.
ggplot(ForFec1718)+
geom_pointrange(aes(x=Month, y=LbAc.mean, ymax=LbAc.Upper, ymin=LbAc.Lower, color=Treatment, shape=TSF,
linetype=TSF, fill=Year), size=1, position = position_dodge(width=0.5),show.legend=TRUE)+
#geom_path(aes(x=Month, y=LbAc.mean, color=Treatment, group=interaction(Treatment,TSF,Year), linetype=TSF),position = position_dodge(width=0.5),
# alpha=0.75, show.legend=FALSE)+
scale_shape_manual(values = c(21,22,23))+
scale_fill_manual(values=c("white", "darkgrey"))+
ylab("Available Forage (Lb/AC)")+
guides(fill = guide_legend(override.aes = list(fill=c("white","darkgrey"))))+
theme_bw()+
theme(legend.position = "bottom",
axis.title=element_text(size=14, face="bold"),
axis.text=element_text(size=12, face="bold"),
panel.grid.major.x = element_blank())
ggplot(ForFec1718)+
geom_pointrange(aes(x=Month, y=LbAc.mean, ymax=LbAc.Upper, ymin=LbAc.Lower, color=Treatment, shape=TSF,
linetype=TSF, fill=Year), size=1, position = position_dodge(width=0.5),show.legend=TRUE)+
geom_path(aes(x=Month, y=LbAc.mean, color=Treatment, group=interaction(Treatment,TSF,Year), linetype=TSF),position = position_dodge(width=0.5),
alpha=0.75, show.legend=FALSE)+
scale_shape_manual(values = c(21,22,23))+
scale_fill_manual(values=c("white", "darkgrey"))+
ylab("Available Forage (Lb/AC)")+
guides(fill = guide_legend(override.aes = list(fill=c("white","darkgrey"))))+
theme_bw()+
theme(legend.position = "bottom",
axis.title=element_text(size=14, face="bold"),
axis.text=element_text(size=12, face="bold"),
panel.grid.major.x = element_blank())
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.