[R] Plotting 2 Lines on the Same Chart

S Ellison S.Ellison at lgc.co.uk
Wed Nov 10 15:23:28 CET 2010


> When I use
>
>> Plot(series1)
>> lines(series2)
>>
>> The graph will use the y axis scaling for series 1 so some of series
2 is
>> cut off.  How do I control the y axis scaling?
>
>Plot them together as a multivariate series as in the examples
already
>pointed to.


...or try 

plot(series1, type="l", ylim=range(pretty(c(series1, series2))) )
lines(series2)

which gives more-or-less sensible ylim scaling based on all the data.
Adding 0 inside the c() will guarantee that zero is in the vertical
scale, too.


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list