Graphics Reference
In-Depth Information
ggplot(BOD, aes(x = Time, y = demand)) +
geom_line(linetype = "dashed" , size = 1 , colour = "blue" )
Figure 4-11. Line graph with custom linetype, size, and colour
If there is more than one line, setting the aesthetic properties will affect all of the lines. On
the other hand, mappingvariables to the properties, as we saw in Making a Line Graph with
Multiple Lines , will result in each line looking different. The default colors aren't the most
appealing, so you may want to use a different palette, as shown in Figure 4-12 , by using
scale_colour_brewer() or scale_colour_manual() :
# 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))
ggplot(tg, aes(x = dose, y = length, colour = supp)) +
geom_line() +
scale_colour_brewer(palette = "Set1" )
Search WWH ::




Custom Search