From ligges at statistik.uni-dortmund.de  Fri Aug 20 15:34:05 2004
From: ligges at statistik.uni-dortmund.de (ligges@statistik.uni-dortmund.de)
Date: Fri Aug 20 15:34:14 2004
Subject: [Rd] mtext adj= wrong with several las= (PR#7188)
Message-ID: <20040820133405.6C06BFCDC@slim.kubism.ku.dk>

joehl@gmx.de wrote:

> Dear all, 
> 
> Our quite basic function mtext() does wrong adjustments in some parameter
> configurations. This gets obvious when using multi line texts: There is no
> way to properly adjust text perpendicular to axis 2, for example.
> 
> Best
> 
> 
> Jens Oehlschl?gel
> 
> 
> m <- matrix(1:9, 3)
> colnames(m) <- c("several\nlines", "several\nlines", "several\nlines")
> 
> par(mfrow=c(2,2))
> barplot(m, horiz=TRUE, axes=FALSE, axisnames=FALSE, main="las=0 adj=0.5 is
> fine")
> mtext(colnames(m), 2, at=seq(0.5+0.2, by=1+0.2, length=3), las=0, adj=0.5)
> barplot(m, horiz=TRUE, axes=FALSE, axisnames=FALSE, main="las=0 adj=1 is
> different")
> mtext(colnames(m), 2, at=seq(0.5+0.2, by=1+0.2, length=3), las=0, adj=1)
> barplot(m, horiz=TRUE, axes=FALSE, axisnames=FALSE, main="las=1 adj=0.5 is
> NOT fine")
> mtext(colnames(m), 2, at=seq(0.5+0.2, by=1+0.2, length=3), las=1, adj=0.5)
> barplot(m, horiz=TRUE, axes=FALSE, axisnames=FALSE, main="at las=1, adj=1
> works the wrong direction", sub="no way to get adj=c(1, 0.5) with las=1 (or
> 2)")
> mtext(colnames(m), 2, at=seq(0.5+0.2, by=1+0.2, length=3), las=1, adj=1)
> par(mfrow=c(1,1))
> 

Left / right adjustemnt seems to be perfectly OK.
The thing that matters is centering "several lines" to the specified 
("at=") location.
In fact, mtext() is not centering but bottom-aligning by adding a 
negative distance that looks OK for one line in the default font size, 
but not in most other cases.

Hence this is the same as Paul Murrell's PR#1659 ("mtext() alignment of 
perpendicular text"). Fixing this, and/or improving mtext()'s "adj" 
argument to accept 2 dimensions is desirable, but might be not that 
easy... I'll take a look during the next days, but nothing promised.

Uwe Ligges



>>version
> 
>          _              
> platform i386-pc-mingw32
> arch     i386           
> os       mingw32        
> system   i386, mingw32  
> status                  
> major    1              
> minor    9.1            
> year     2004           
> month    06             
> day      21             
> language R   
> 
>


[Rd] mtext adj= wrong with several las= (PR#7188)
ligges@statistik.uni-dortmund.de