[R] controlling plot range

James jctoll at gmail.com
Fri Oct 19 19:01:07 CEST 2007


On Oct 19, 2007, at 10:54 AM, John Sorkin wrote:

> Windows XP
> R 2.5.0
> I am trying to produce two plots that have the same range, i.e. x  
> from 50 to 400 on both plots and y from 50 to 400 on both plots.  
> (This will allow me to compare slopes). I have used the code below  
> without success using usr (I have also used xaxp and yaxp but I am  
> not including the code):
>
> plot(tgNo26[,"TGh"],tgNo26[,"TGs"],usr=c(50,400,50,400))
> plot(tgNo26[grep("CONTROL",tgNo26[,"PATIENT"]),"TGh"],
>      tgNo26[grep("CONTROL",tgNo26[,"PATIENT"]),"TGs"],usr=c 
> (50,400,50,400))
>
> RESULT:
> axes on first plot 50-400, y axis 50-350
> axes on second plot 50-250 y axis 100-250

From

?plot.default

Are you looking for:

xlim		the x limits (x1, x2) of the plot. Note that x1 > x2 is allowed  
and leads to a “reversed axis”.
ylim		the y limits of the plot.

I believe this will allow you to set the axes to the same limits so  
that you can compare more easily.

HTH

James



More information about the R-help mailing list