[R] mtext uses the typographical descender to align text

Andreas Svensson andreas.svensson at bio.ntnu.no
Mon Aug 14 15:57:01 CEST 2006



One sometimes (quite often really ) marvel at the choice of defaults in 
R's graphic engine.
For some obscure reason, mtext uses the typographical  descender (bottom 
of letters) to align text. That is: "gG" will end up slightly higher 
that "GG". Depending on the font, "Q" might end up higher than "O".

(for explanation of baseline & descender see: 


y1 <- rnorm(30)
y2 <- rnorm(30)
group <- as.factor(rep(1:6, each=10))
y <- c(y1,y2)
testdata <- data.frame(group, y)
plot (y ~group, axes=F, xlab="why does R align the BOTTOM of the 
letters???" )
mtext(expression(italic("Normal 1"))   ,1 ,  line=1, at=1)
mtext(expression(italic("Higher 1 "))  ,1 ,  line=1, at=2)
mtext(expression(italic("Normal 3 "))  ,1 ,  line=1, at=3)
mtext(expression(italic("Higher 2 "))  ,1 ,  line=1, at=4)
mtext(expression(italic("Normal 3 "))  ,1 ,  line=1, at=5)
mtext(expression(italic("Higher 3 "))  ,1 ,  line=1, at=6)

As the word "Higher" includes a descending letter (g), this factor name 
ends up higher.
I must say I have never encountered a software that uses the 
typographical descender instead of the baseline to align text .

Does anyone know how to make R use the baseline instead? Perhaps using  
adj or padj? Or do I have to do something silly as adding
"g", col=white
to each mtext-line to trick R into aligning the names.


More information about the R-help mailing list