The first thing I would try is to define the aesthetics only once and do so in the ggplot()
function. Ie.
ggplot(data=dataset,aes(x=Time,y=Mean,colour=Code,linetype=Group,ymin=Mean-SE,ymax=Mean+SE)) +
geom_line() +
scale_x_continuous(breaks=c(1,2)) +
scale_linetype_manual(values=c(2,1)) +
geom_point() +
geom_errorbar(width=.1,position='dodge')
This is because ggplot
doesn't guarantee to pass all of the variables that are in the original dataset and weird results can result from depending on this.
Edit: I just noticed that x
never gets defined for geom_errorbar
, adding x=Time
to either the aes
of ggplot()
or geom_errorbar()
should fix the problem. However, doing the latter is really not recommended.
If you give example data (eg. dput
) I would be able to help you further.