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