There is an example in the example section of plotting two time series on the same plot with different left hand and right hand scales here:
library(zoo) ?plot.zoo On 3/2/07, Berta <[EMAIL PROTECTED]> wrote: > > Hi R-Users, > > I am trying to plot two time series in the same plot, but they measure > different things and hence one > has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around > 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both > in the same graph but with two axes, one from 1 to 9 and the other from 20 > to 100. To do so, I needed to do a regression for corrsepondence (1 goes to > 20 and 9 goes to 100); the code to produce the graph would be: > > plot(1996:2000, xlim=c(1996, 2000),ylab="Resistence", ylim=c(20,100), > type="n", xlab="Date") > lines(1996:2000, c(80, 100, 95, 35, 28), col=1) > axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) > lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ > lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) > legend(1998.5, 90, legend=c("Resistence", "Use"), fill=c(1,2)) > > However, I suspect there are better ways to do so, and I would like to know > one because I have to do that many times. > > Thanks a lot in advance, > > Berta > > ______________________________________________ > R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.