Hi
This is a basic "feature" of both strheight() and stringHeight(). They
both ignore any descenders in the text. I cannot remember why it was
done this way originally. The future solution is probably to add an
argument that allows descenders to be included in text height.
Plotmath works on bounding boxes so its behaviour is different, but of
course that has its own problems because there is no sense of "baseline"
for expressions.
Paul
On 27/04/2011 11:06 a.m., baptiste auguie wrote:
Dear all,
I'm puzzled by the behavior of stringHeight in the grid package.
Consider the following test,
library(grid)
test<- function(lab="dog", ...){
g1<- textGrob(lab)
g2<- rectGrob(height=grobHeight(g1), width=grobWidth(g1))
gg<- gTree(children=gList(g1,g2), ...)
print(c("height:", convertUnit(stringHeight(lab), "mm", "y")))
grid.draw(gg)
}
grid.newpage()
test()
test(expression(dog), vp=viewport(x=0.6))
## notice how the dog's tail is being cut off, where
## expression yields a snug cage
grid.newpage()
test("aoc")
test(expression(aoc), vp=viewport(x=0.6))
It appears that stringHeight correctly calculates the height for an
expression, but not for a basic string. I think it used to produce the
same output for both.
Best regards,
baptiste
sessionInfo()
R version 2.13.0 alpha (2011-03-27 r55076)
Platform: i386-apple-darwin9.8.0 (32-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets grid methods
[8] base
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel