According to Hadley's ggplot book (p. 109), both the graphs below should have a legend, and yet none appears in my hands.
Any suggestions? I can't see a typo. Is there a bug? library(ggplot2) data(LakeHuron) huron = data.frame(year=1875:1972,level=LakeHuron) p = ggplot(huron, aes(year)) + geom_line(aes(y= level - 5), colour = 'blue') + geom_line(aes(y= level + 5), colour = 'red') print(p) key = c('below' = "blue", 'above' = "red") p = p + scale_color_manual("Direction", values = key) print(p) > sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] ggplot2_0.8.9 proto_0.3-8 reshape_0.8.4 plyr_1.4 loaded via a namespace (and not attached): [1] tools_2.12.1 > # on Windows XP > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 12.1 year 2010 month 12 day 16 svn rev 53855 language R version.string R version 2.12.1 (2010-12-16) > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.