[R] ggplot2 / time series with different scales
xiechaos at gmail.com
Thu Feb 4 18:59:57 CET 2010
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')
On Fri, Feb 5, 2010 at 12:22 AM, Dieter Menne
<dieter.menne at 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.
> 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 at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help