[R] Two Y-axises and One X-axis

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Nov 7 19:22:25 CET 2003


umeno wrote:

> Hi,
> 
> I would like to know if anyone knows how to draw a plot with two Y-axises and 
> one X-axis? When you have two sets of y values that do not have the same 
> scale, but correspond to the same x value, I would like to plot them on one 
> graph.
> 
> Could you please help me?

Please look into the help archives before asking! This question has been 
answered several times during the last years.

Example for a short solution:

   plot(1:10)
   par("usr")
# [1]  0.64 10.36  0.64 10.36
# Now resetting y-axis' usr coordinates:
   par(usr=c(par("usr")[1:2], 101, 105))
   points(1:5, 105:101, col="red")
   axis(4)


Uwe Ligges




More information about the R-help mailing list