[R] Plotting w/multiple y-axes?

kjetil brinchmann halvorsen kjetil at entelnet.bo
Mon Jan 20 15:53:03 CET 2003


On 20 Jan 2003 at 18:51, Per Bak wrote:

Hola!

I think this have been asked (and answered) many times, so you
could have tried to search the archives!

But, a simple example:

> x <- 1:10
> y1 <- 1:10
> y2<- rev(seq(1,1000, length=10))
> y2
 [1] 1000  889  778  667  556  445  334  223  112    1
> plot(x,y1,ann=FALSE)
> axis(2, at=c(2,4,6,8), labels=as.character(c(2,4,6,8)))

# this gives a mark at 10 also! a bug?

> points(x,y2/100,col="red")
> axis(4, at=c(2,4,6,8), labels=as.character(c(200, 400, 600, 800)))
> 


Kjetil Halvorsen

> How do I plot using multiple(2) y-axes? 
> I have two series that use the same x-data, but have very different scales. 
> 
> Appreciate any feedback,
> 
> Per Bak
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list