Hi Norman, This is pretty easy in ggplot2 (if you adjust your data a little):
install.packages("ggplot2") library(ggplot2) days <- seq(Sys.Date(), len=100, by="1 day") df <- data.frame( date = rep(days, each = 3), trt = rep(c("A", "B", "C"), 50), price = runif(150) ) qplot(date, price, data=df, geom="bar", stat="identity", fill=trt) qplot(date, price, data=df, geom="bar", stat="identity", fill=trt, position = "fill") qplot(date, price, data=df, geom="bar", stat="identity", fill=trt, position = "fill") + scale_fill_grey() Hadley On Fri, Sep 26, 2008 at 8:36 AM, Rubin, Norman <[EMAIL PROTECTED]> wrote: > I've just used r a little, so this might be a trivial question but > > > > I have a small data file > > part, vs/total ,ps/total, gpgpu, date > > ... ... ... ... .. > > > > that contains the percent that certain features contribute to a part and > the date the part was built > > > > > > I'd like to do stacked bar graphs one bar per part showing the percents > > and I'd like tospace the bars based on the date released > > > > I tried > > > > area <- read.csv("c:/talks/pact2008/g1.csv"); > > dates <-strptime(as.character(area$date), "%m/%d/%Y") > > > > ## hack to figure out the amount to shift the bars > > l <- length(as.POSIXct(dates)) > > diff <- as.numeric(difftime(dates[2:l], dates[1:(l-1)])) > > diff <- rev(diff/max(diff)) > > > > colors <- gray.colors(3) > > > > > > data <- c(area$ps.total[1:5], area$vs.total[1:5], area$gpgpu[1:5]) > > > > data <- 100*t(matrix(data, 5, 3)) > > > > ## the .6 makes the bars look a little lighter, I did ths by eye > > barplot(data, space=diff+.6) > > > > > > > > This works giving me the graph I want, but it seems so clunky, what is a > better way? > > > > > > I do get a warning > > > > Warning messages: > > 1: In space + width : > > longer object length is not a multiple of shorter object length > > 2: In space + width : > > longer object length is not a multiple of shorter object length > >> > > > > making me think I'm not understanding how space works. I don't > understand how to set width, what kind of units would it be in? > > > > > [[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. > -- http://had.co.nz/ ______________________________________________ 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.