[R] How to extract the upper xlim and ylim of my plot?

Marc Schwartz marc_schwartz at me.com
Tue Jul 21 23:15:46 CEST 2009


On Jul 21, 2009, at 4:03 PM, Mark Na wrote:

> Dear R-helpers,
>
> I wish to place some text in a plot, at approx 10% of my upper xlim  
> and
> approx 90% of my upper ylim, i.e.
>
>> plot(log(all$SR,10)~log(all$AREA,10))
>> text(.1*max(xlim),.9*max(ylim),"text to be placed")
>
> (I know how to give absolute coordinates for text location, but I  
> wish to
> use relative coordinates).
>
> My code (above) doesn't work because I don't know how to properly  
> extract
> the upper xlim and ylim values.
>
> Does anyone know how I could extract the upper xlim and ylim values  
> (without
> using max(x-variable) or max (y-variable)...I wish to keep this as  
> general
> as possible and not point to the original data.
>
> Thanks in advance,
>
> Mark

Mark,

   par("usr")

after the plot has been created will give you the x,y corner extremes  
of the plot region in user coordinates.

See ?par and scroll down to 'usr'.

HTH,

Marc Schwartz




More information about the R-help mailing list