Graphics Reference
In-Depth Information
ggplot(tg, aes(x = dose, y = length, shape = supp)) + geom_line() +
geom_point(size = 4 )
# Make the points a little larger
ggplot(tg, aes(x = dose, y = length, fill = supp)) + geom_line() +
geom_point(size = 4 , shape = 21 ) # Also use a point with a color fill
Figure 4-9. Left: line graph with different shapes; right: with different colors
Sometimes points will overlap. In these cases, you may want to dodgethem, which means their
positions will be adjusted left and right ( Figure 4-10 ) . When doing so, you must also dodge the
lines, or else only the points will move and they will be misaligned. You must also specify how
far they should move when dodged:
ggplot(tg, aes(x = dose, y = length, shape = supp)) +
geom_line(position = position_dodge( 0.2 )) + # Dodge lines by 0.2
geom_point(position = position_dodge( 0.2 ), size = 4 ) # Dodge points by 0.2
Search WWH ::




Custom Search