[R] Specifying relative position of text in a plot

Bill.Venables at csiro.au Bill.Venables at csiro.au
Thu Mar 13 01:16:10 CET 2008


Here is one way.

...
usr <- par("usr")  		# get user coordinates
par(usr = c(0, 1, 0, 1)) # new relative user coordinates

text(0.1, 0.5, "Some text", adj = 0)  # if that's what you want

par(usr = usr)			# restore original user coordinates

...

If you were going to be doing this a lot, you could write a simple
wrapper function to text(...) to incorporate this change to relative
coordinates and back again.

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Tom La Bone
Sent: Thursday, 13 March 2008 12:34 AM
To: r-help at r-project.org
Subject: [R] Specifying relative position of text in a plot


What is the simplest way to specify the location of text in a scatter
plot
(created using the plot function) in relative terms rather than specific
x-y
coordinates? For example, rather than putting text at (300,49) on a
plot,
how do I put it 1/10 of the way over from the y axis and 1/2 of the way
up
from the x axis? Thanks.

Tom 
-- 
View this message in context:
http://www.nabble.com/Specifying-relative-position-of-text-in-a-plot-tp1
6002549p16002549.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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