[R] text length in grid
kevin bartz
kbartz at loyaltymatrix.com
Tue Jun 29 00:30:49 CEST 2004
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, so I would like to label each by fitting its text to the size of
the region in question. Ideally, I could have nice, big text labeling the
big regions and tiny type in the small regions.
Let me try to illustrate my scenario. Imagine that my plot looks like this:
pushViewport(viewport(layout = grid.layout(5, 2, c(9,1), 1:5)))
for (i in 1:5) {
pushViewport(viewport(layout.pos.row = i, layout.pos.col = 1))
pushViewport(viewport(x = 0, width = i/5, height = .8, just = "left"))
grid.rect(gp = gpar(fill = rainbow(5)[i]))
grid.yaxis(main = F)
grid.text("I am some descriptive text.")
popViewport()
popViewport()
}
Unfortunately, the descriptive text overlaps with the axis for the red
rectangle! Is there any way, given the dimensions of some region on the grid
and the desired text, that I can fit this text to the region?
Sorry if I missed something in the documentation. I really did look at
?grid.text, all the documentation for the grid package, all the PDFs posted
on the grid page as well as previous r-help postings, but none seemed to
address this question. Thanks so much for any help you can provide!
Kevin
More information about the R-help
mailing list