[R] Two lines, two scales, one graph

Patrick Connolly p_connolly at slingshot.co.nz
Mon Aug 24 21:51:29 CEST 2009


On Mon, 24-Aug-2009 at 08:00AM -0700, Rick wrote:

>
> First of all, thanks to everyone who answers these questions - it's
> most helpful.
>
> I'm new to R and despite searching have not found an example of what I
> want to do (there are some good beginner's guides and a lot of complex
> plots, but  I haven't found this).
>
> I would like to plot two variables against the same abscissa values. They
> have different scales. I've found how to make a second axis on the right
> for labeling, but not how to plot two lines at different scales.

The idea is that you rescale the second lot of y values to fit into
the same range as the first lot.  

If your first ones range from 0 to 10 and your second ones from 0 to
1000, you do the second line (using the lines() function) by dividing
every value by 100 and I think you will have found how to use axis
with side = 3 to do the axis.  If the zeros don't coincide, you need
to make further adjustments which should become obvious.

HTH



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.




More information about the R-help mailing list