[R] plot y1 and y2 on one graph

Jim Lemon jim at bitwrit.com.au
Thu Feb 28 11:16:20 CET 2008


milton ruser wrote:
> Dear all
> 
> I have a code like
> 
> x<-1:10
> y1<-x+runif(10)*2
> y2<-seq(0,50,length.out=10)+rnorm(10)*10
> 
> par(mfrow=c(1,2))
> plot(y1~x)
> plot(y2~x)
> 
> Now I would like to plot y1 and y2 on the same graph, with its two scales
> (y1 on left and y2 on rigth side).
> 
Hi Miltinho,
twoord.plot in the plotrix package might do the job for you.

twoord.plot(x,y1,x,y2)

Jim



More information about the R-help mailing list