[R] ggplot legend for multiple time series

Edwin Sun csun at cfr.msstate.edu
Tue Dec 1 20:02:53 CET 2009


Hello All,

I am trying to create a legend for a black-white graph. The package I use is
ggplot2. It can add colors to the legend key but not line types. Can you
please help?

# example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
page 109)

library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
    geom_line(aes(y=level+5, colour="above")) +
    geom_line(aes(y=level-5, colour="below")) +
    scale_colour_manual("Direction", c("above"="black", "below"="black"))

Thanks,


Edwin

Changyou Sun, Ph.D.
Associate Professor
Natural Resource Policy & Economics
Box 9681, Department of Forestry
Mississippi State University
Mississippi State, MS 39762

#363 Thompson Hall
(662) 325 7271 (ph), 325 8726 (fax)
csun at cfr.msstate.edu
www.cfr.msstate.edu/forestry
-- 
View this message in context: http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list