Hi: I've searched the archives and the Internet for hours but have yet to find a way to do stacked area plots (like the kind in Excel) in R. I think that polygon may work but it would require a bit of manipulation of my data. I was hoping for an easier way. An example of what I'm trying to do can be found here: http://jcharts.sourceforge.net/samples/stackedArea.html Thanks, Josip
On Wed, Sep 17, 2008 at 1:01 PM, Josip Dasovic <jjd9 at sfu.ca> wrote:> Hi: > > I've searched the archives and the Internet for hours but have yet to find a way to do stacked area plots (like the kind in Excel) in R. I think that polygon may work but it would require a bit of manipulation of my data. I was hoping for an easier way. > > An example of what I'm trying to do can be found here: > http://jcharts.sourceforge.net/samples/stackedArea.htmlThese are pretty easy in ggplot2: df <- data.frame( trt = rep(letters[1:3], each = 10), year = rep(1:10, 3), value = abs(rnorm(30)) ) install.packages("ggplot2") library(ggplot2) qplot(year, value, data=df, geom="area", fill = trt) Hadley -- http://had.co.nz/
The example pointed to below is a good example of fortune(197). It is possible to do using polygon (and is probably not as hard as you are making it), but there is probably a better way to present your data. What question are you trying to answer with this plot?> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Josip Dasovic > Sent: Wednesday, September 17, 2008 12:02 PM > To: r-help at r-project.org > Subject: [R] Stacked Area Plot > > Hi: > > I've searched the archives and the Internet for hours but have yet to > find a way to do stacked area plots (like the kind in Excel) in R. I > think that polygon may work but it would require a bit of manipulation > of my data. I was hoping for an easier way. > > An example of what I'm trying to do can be found here: > http://jcharts.sourceforge.net/samples/stackedArea.html > > Thanks, > Josip > > ______________________________________________ > R-help at 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.
Josip Dasovic wrote:> Hi: > > I've searched the archives and the Internet for hours but have yet to find a way to do stacked area plots (like the kind in Excel) in R. I think that polygon may work but it would require a bit of manipulation of my data. I was hoping for an easier way. > > An example of what I'm trying to do can be found here: > http://jcharts.sourceforge.net/samples/stackedArea.html > >Hi Josip, Look at stackpoly in the plotrix package. Jim
Apparently Analagous Threads
- Change color of plot points based on values of a variable
- Calculating total observations based on combinations of variable values
- Drawing Polygons with xyplot in lattice
- Data Frame Manipulation: Time Series
- Generating new variable based on values of an existing variable