[R] text length in grid

2004-06-28 Thread kevin bartz
Hello! I first would like to compliment the authors of grid on what has been a wonderfully useful package for me. Now, my question: Is there any way I can specify the size of some grid.text using grid units? I must label the regions of a plot. The regions can be either very small or very large,

Re: [R] text length in grid

2004-06-28 Thread Paul Murrell
Hi Here's one way to do it: fitText - function(text) { tw - convertWidth(stringWidth(text), inches, valueOnly=TRUE) vw - convertWidth(unit(1, npc), inches, valueOnly=TRUE) cex - vw/tw grid.text(text, gp=gpar(cex=cex)) } pushViewport(viewport(layout = grid.layout(5, 2, c(9,1), 1:5))) for (i