Graphics Reference
In-Depth Information
For line graphs, if the error bars are a different color than the lines and points, you should draw
the error bars first, so that they are underneath the points and lines. Otherwise the error bars will
be drawn on top of the points and lines, which won't look right.
Additionally, you should dodge all the geometric elements so that they will align with the error
bars, as shown in Figure 7-16 :
pd <- position_dodge( .3 ) # Save the dodge spec because we use it repeatedly
ggplot(cabbage_exp, aes(x = Date, y = Weight, colour = Cultivar, group = Cultivar)) +
geom_errorbar(aes(ymin = Weight - se, ymax = Weight + se),
width = .2 , size = 0.25 , colour = "black" , position = pd) +
geom_line(position = pd) +
geom_point(position = pd, size = 2.5 )
# Thinner error bar lines with size=0.25, and larger points with size=2.5
Figure 7-16. Error bars on a line graph, dodged so they don't overlap
Notice that we set colour="black" to make the error bars black; otherwise, they would inherit
colour . We also made sure the Cultivar was used as a grouping variable by mapping it to
group .
Search WWH ::




Custom Search