you can use facet_wrap: df <- melt(df, id=c('time', 'sid')) ggplot(df, aes(time, value, colour=sid)) + geom_line(data = subset(df, variable=='sales')) + geom_point(data = subset(df, variable=='price')) + facet_wrap(~variable, ncol=1, scales='free_y')
Xie Chao On Fri, Feb 5, 2010 at 12:22 AM, Dieter Menne <dieter.me...@menne-biomed.de> wrote: > > > chuckwhite wrote: >> >> I am trying to plot this dataset using ggplot2: >> >> .. self-contained example removed >> >> How can I plot the price (using geom_point) in a separate plot just above >> the sales plot so that the xaxes match and the yaxes are different. >> >> > To quote Hadley Wickham: http://markmail.org/message/xbuecsbudjxkmqkf > > "However, what you describe sounds like you want multiple scales on a single > plot - and that's not something that ggplot is likely to ever support" > > One alternative would be to use free scales on separate plot. Or even > better, a plot of sales against price? I know, executives and clinic head > have troubles understanding these. > > Dieter > > > -- > View this message in context: > http://n4.nabble.com/ggplot2-time-series-with-different-scales-tp1469011p1469030.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > ______________________________________________ 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.