[R] Specifying relative position of text in a plot

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 12 16:13:09 CET 2008


See ?par, entry "usr". Either set a new coordinate system and use it, or 
convert 1/10 to user coordinates.

In R-devel (2.7.0 to be) this is easier:

    text(grconvertX(0.1,"npc"), grconvertY(0.5, "npc"), "some text")

cnvrt.coords() in package TeachingDemos does something similar (although 
it doesn't use the standard R names for coordinate systems, and there are 
more than 5).

On Wed, 12 Mar 2008, Tom La Bone wrote:

>
> 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


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list