[R] Character height & width in user co-ordinates

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon May 17 08:49:29 CEST 1999


On Mon, 17 May 1999, John Maindonald wrote:

> Is there an equivalent to the S-PLUS par()$cxy in R?

That is specified as giving:

cxy=c(x1,y1)    character size (width and height) in usr coordinates.

When I needed this (V&R2, p.74) I used for the height yinch(par("csi")).
The width is a lot less clearcut, since R (and indeed S-PLUS) allows
variable-width fonts. I would use strwidth() to find the actual width.
There is also strheight(), but I think that computes the actual
height rather than the nominal height given by par("cxy").

I think that  (0.57*xinch(par("csi")), yinch(par("csi"))) is a reasonable
substitute, 0.57 coming from some experiments I did when I first
encountered this.

> Also, is it possible to get notice taken of some 
> equivalent of \n in R when using text()?
> For what it is worth I am using RW-0.64.1.

The NEWS file says: 

                CHANGES IN R VERSION 0.64.0

    o   Support for handling embedded '\n's in text strings
        handed to low-level graphics functions has been added.
        Some changes to the PostScript graphics driver were
        needed to support this, so there may some minor change
        in the appearance of plots produced in PostScript.

but this does not work for me even on postscript devices on Unix.
e.g.

plot(1:3, 1:3)
text(1, 2, "test1\ntest2\ntest3")

This does however work on R-0.65.0, so you might like to compile up the 
current development version. (Can someone explain that comment? Is it
just premature?)

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list