Skip to content
Prev 268525 / 398502 Next

Grid unit width and font face

Hi
On 8/13/2011 9:49 AM, Prof Brian Ripley wrote:
And another is to create a text grob and use grobWidth() instead of 
stringWidth() ...

gt <- textGrob("Some text", gp=gpar(cex=2))
grid.draw(gt)
grid.rect(width=grobWidth(gt))

... and another is to provide a name when you draw the text and then 
supply grobWidth() with a gPath rather than a grob ...

grid.text("Some text", gp=gpar(cex=2), name="mylabel")
grid.rect(width=grobWidth("mylabel"))

Paul