[R] Two y-axis in plots

Jerome Asselin jerome at hivnet.ubc.ca
Fri Apr 4 10:02:08 CEST 2003


See the axis() function.

x <- rnorm(20)
y<- rnorm(20)
plot(x,y)
axis(4,at=-3:3,labels=(-3:3)*10)
axis(3,at=-3:3,labels=letters[1:7])

You may want to also consider plot(x,y,xaxt="n",yaxt="n") to suppress the 
x and y axes which you can rebuild with axis() to fit your purpose. See 
also the help file on par() for all kinds graphicals arguments. E.g., you 
may have to reset your margins with the "mai" options if you need enough 
space to include a label on the right axis.

Jerome

On April 3, 2003 02:53 am, Allan McRae wrote:
> Hi,
>
> I am trying to plot two data sets on one plot but with using a different
> y-axis ranges for each - preferably with one shown on each side of the
> graph.
>
> Is there a function that will allow me to do this.
>
> Thanks
>
> Allan McRae
> 	[[alternate HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help



More information about the R-help mailing list