[R] time series with diff. y axes

Erin Hodgess hodgess at gator.uhd.edu
Tue Mar 2 22:56:07 CET 2004


Dear R People:

Someone had asked a question about plotting 2 time series
with different y-axes.  There is a nice example in S+, but here is
a toy example (modified from the S+ example) which someone may find
useful:

> y1 <- rnorm(48)
> y2 <- rnorm(48)
> y1.ts <- ts(y1,start=c(1996,1),freq=12)
> y2.ts <- ts(y2,start=c(1996,1),freq=12)
> par(mar=rep(5,4))
> plot(y1.ts,ylab="Horses")
> par(new=T)
> plot(window(y2.ts,start(y1.ts),end(y1.ts)),lty=2,
+ axes=F,ylab=" ")
> axis(4)
> mtext("Hounds",side=4,line=3)
> title(main="Horses and Hounds")
> 

Hope this helps!

Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu




More information about the R-help mailing list