[R] How can strheight be calculated in lattice/grid?

Deepayan Sarkar deepayan at stat.wisc.edu
Mon Oct 27 15:56:50 CET 2003


On Monday 27 October 2003 03:50, Wolfram Fischer wrote:
> If I have drawn a string with ``ltext( x, y, labels="first string" )''
> how can a draw a second string just one line (or strheight("X")
> below the first string regardless of the size and scales of the panel?

No reliable (that is, documented and guaranteed not to change) way I can think 
of. But in this situation you should directly use grid.text instead. e.g., 

xyplot(1 ~ 1,
       panel = function(x, y, ...) {
           grid.text("first string", unit(x, "native"), unit(y, "native"))
           grid.text("second string", unit(x, "native"),
                     unit(y, "native") - unit(1, "lines"))
       })

There are several other useful 'unit' systems you can use concurrently in 
grid, see ?unit for details.

(In the default scenario, you can replace the first grid.text call by ltext, 
but they could potentially be different because ltext honours some trellis 
settings which grid.text doesn't.)

Deepayan




More information about the R-help mailing list