Graphics Reference
In-Depth Information
Figure 4-15. Points with a white fill
If the points and lines have different colors, you should specify the points after the lines, so that
they are drawn on top. Otherwise, the lines will be drawn on top of the points.
For multiple lines, we saw in Making a Line Graph with Multiple Lines how to draw differently
colored points for each group by mapping variables to aesthetic properties of points, inside of
aes() . The default colors are not very appealing, so you may want to use a different palette, us-
ing scale_colour_brewer() or scale_colour_manual() . To set a single constant shape or
size for all the points, as in Figure 4-16 , specify shape or size outside of aes() :
# Load plyr so we can use ddply() to create the example data set
library(plyr)
# Summarize the ToothGrowth data
tg <- ddply(ToothGrowth, c( "supp" , "dose" ), summarise, length = mean(len))
# Save the position_dodge specification because we'll use it multiple times
pd <- position_dodge( 0.2 )
ggplot(tg, aes(x = dose, y = length, fill = supp)) +
geom_line(position = pd) +
Search WWH ::




Custom Search