ggplot(dat.melt,aes(x=width,y=value,fill=variable,colour=variable))+geom_density(stat='identity',alpha=0.5)
the fill and colour variables can be removed if you want. or ggplot(dat.melt,aes(x=width,y=value,fill=variable))+geom_density(stat='identity',alpha=0.5)+facet_wrap(~variable,ncol=1) same with this version. On Thu, Jan 12, 2012 at 9:35 AM, Mary Kindall <mary.kind...@gmail.com>wrote: > Hi this is exactly what i am looking for but I do not like to draw as > histogram instead I want two separate plot for this data. Something like > the ones shown in the following link. Please disregard the legends of the > following fig. > > > http://had.co.nz/ggplot2/graphics/55078149a733dd1a0b42a57faf847036.png > > http://had.co.nz/ggplot2/graphics/90983232ced45a93d9fbbe40afffd69a.png > > Thanks > > On Thu, Jan 12, 2012 at 12:13 PM, Justin Haynes <jto...@gmail.com> wrote: > >> On Thu 12 Jan 2012 09:02:27 AM PST, Mary Kindall wrote: >> >>> Hi >>> I have a data frame in the following form. There are two groups and for >>> each 'width' relative frequency for group1 and group2 is given. How to >>> plot >>> this in R using ggplot or other package. >>> >>> >>> Width relativeFrequency1 relativeFrequency2 >>> 1 100 0.0006388783 0.02265428 >>> 2 200 0.0022677303 0.02948625 >>> 3 300 0.0061182673 0.01739936 >>> 4 400 0.0152237225 0.02569902 >>> 5 500 0.0300215262 0.03639880 >>> 6 600 0.0597610250 0.07717765 >>> >>> >>> Thanks >>> >>> >> not sure exactly what you're looking for but... >> >> dat<-data.frame(width=1:6*100,**rel1=runif(6), rel2=runif(6)) >>> dat.melt<-melt(dat,id.var='**width') >>> ggplot(dat.melt,aes(x=factor(**width),y=value,fill=variable))** >>> +geom_bar(stat='identity',**position='dodge') >>> >> >> >> > > > -- > ------------- > Mary Kindall > Yorktown Heights, NY > USA > > [[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.