Wolfram Fischer
2003-Oct-27 09:50 UTC
[R] How can strheight be calculated in lattice/grid?
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? Thanks Wolfram
Deepayan Sarkar
2003-Oct-27 14:56 UTC
[R] How can strheight be calculated in lattice/grid?
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