R-listers: I am summarizing input I got on a recent query about creating stacked, colored line plots in xyplot. The only input I got regarding xyplot was to use the polygon() command, but this seemed to require some awkward data manipulation. In contrast, I got several snippets of functional code for use in the ggplot2 and plotrix packages, both of which produced nice graphs with minimal effort. (Apparently the filled bands option in the xYplot function in the Hmisc package will also do this).
### stacked line graphs in plotrix package x <-matrix(x,nrow=10) # create matrix of x values y <-matrix(y,nrow=10) # create matrix of y values stackpoly(x,y,stack=TRUE) # make the graph ### stacked line graphs in ggplot2 package x <- rep(seq(1,10), 2) # create column of x values y <- c(1+1.5*(1:10), 0.2 + 1.3*(1:10) ) # create column of y values trt <- rep(c("low", "high"), each = 10) # create column with identify of treatments qplot(x, y, fill=trt, geom="area") # plot the graph I ended up using ggplot2, because I had to churn out a large number of these, and the "facets" command allowed me to make panels in a manner akin to the lattice system. Thanks to Carl, Hadley, Xie, Jim and Frank for responding. --Seth Bigelow Dr. Seth W. Bigelow Biologist, Sierra Nevada Research Center Pacific Southwest Research Station, USDA Forest Service. 1731 Research Park Drive, Davis CA 95618 ______________________________________________ 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.