[R] Second axis in a plot

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Jun 17 15:48:58 CEST 2002


Juan Cuervo <juan_l_cuervo at yahoo.es> writes:

> Hi to all,
> First of all, I prefer to tell that I am a R-newbie,
> so I apologize if this is a silly question (I have
> tried looking in the manuals, but without luck).
> I have two variables, y and z, that I want to plot
> against x in the same plot. I have done this before,
> using points() after plot(). But now the problem is
> that y and z are in different units of measurement,
> and their ranges are very different.
> I have tried drawing a second axis with axis(), but I
> found the same problem: the new axis is drawn in the
> same range than the first variable plotted in the
> y-axis.
> I would greatly appreciate some suggestions.
> Regards,
> Juan L. Cuervo

The trick is to rescale z into y coordinates, and then axis(3, at=...,
labels=...) where "at" is in y coordinates, but the labels are given
as z coordinates.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list