You to set the dodge
width
to the same value for all geom
s, i.e. add position = position_dodge(width = <the-desired-width>)
to each of them. See What is the width argument in position_dodge? for details.
# set desired dodge width
pd <- position_dodge(width = 0.4)
ggplot(YearlyDensity, aes(x = Year, y = mean, colour = Station, group = Station)) +
geom_errorbar(aes(ymin = mean-se, ymax = mean+se),
colour = "black", width = 0.2, position = pd) +
geom_line(size = .8, position = pd) +
geom_point(size = 4, shape = 18, position = pd) +
coord_cartesian(ylim = c(0, 16000)) +
scale_y_continuous(breaks = seq(0, 16000, 2000)) +
xlab("Sampling Year") +
ylab("Mean Density") +
labs(fill = "") +
theme_bw() +
theme(legend.justification = c(1, 0), legend.position = c(1, 0))