As an example, I have this data frame, called my_data
:
Groups FactorA FactorB FactorC N value sd se
Put the data for the segment in data frame and also add columns FactorB
and FactorC
with levels for which you need to draw the segment.
data.segm<-data.frame(x=0.8,y=100,xend=1.2,yend=100,
FactorB="Condition1",FactorC="Condition1")
Now use this data frame to add segment. Also add inherit.aes=FALSE
inside geom_segment()
to ignore fill=FactorA set in ggplot().
+ geom_segment(data=data.segm,
aes(x=x,y=y,yend=yend,xend=xend),inherit.aes=FALSE)+