Re: [R] mtext uses the typographical descender to align text

From: Peter Dalgaard <>
Date: Tue 15 Aug 2006 - 00:33:15 EST

Andreas Svensson <> writes:

> <>
> Hello
> 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:
> mtext(expression(italic("Normal 1")) ,1 , line=1, at=1)
> 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.

Notice that it only happens when plotting math expressions. Using

 mtext("Normal 1" ,1 , line=1, at=1,font=3)  mtext("Higher 1 " ,1 , line=1, at=2, font=3) etc.

does not exhibit the same effect.

I suppose the idea is that math expressions can grow arbitrarily tall or deep, and that the design decision (wise or not) has been to align on the bounding box of the whole enchilada. For a workaround, if you do need to do it with expressions, notice the phantom() construction.

   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Aug 15 00:43:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 15 Aug 2006 - 02:23:28 EST.

Mailing list information is available at Please read the posting guide before posting to the list.