[R] controlling plot range

Bert Gunter gunter.berton at gene.com
Fri Oct 19 19:49:07 CEST 2007


John:

I agree: the Docs are not clear on this. V&R's MASS (p.84 in the 4th
edition) gives an explanation:

"Positions in the plot region may also be specified in absolute **user
coordinates**.  Initially user coordinates and relative coordinates
[..relative to the unit square of the enclosing region--BG] coincide,, but
any high-level plotting function changes the user coordinates so that the x-
and y- coordinates range from their minimum to maximum values as given by
the plot axes."

As James said, xlim and ylim is what you want. A more extensive discussion
and examples of the use of usr coordinates can be found in Paul Murrell's R
GRAPHICS book, pp. 99 -105.

Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of James
Sent: Friday, October 19, 2007 10:01 AM
To: John Sorkin
Cc: r-help at r-project.org
Subject: Re: [R] controlling plot range

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

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list