[Rd] axis, title & padj

Philip Johnson plfjohnson at emory.edu
Wed Mar 2 23:38:02 CET 2011


Hi,

I often use par(mex = 0.5) as an easy way to shrink space used for 
margins.  However, I recently noticed that this leads to an asymmetry in 
the positioning of the x vs. y axis labels and xlab / ylab -- the x-axis 
labels are pushed into the tic-marks, while the y-axis labels look fine.

A more extreme example:
dev.new()
par(mex=.1, mar=c(10,10,10,10))
plot(1:10)

Tracking this down in the code, this effect appears to be arising from:
   1) GMtext in graphics.c adjusts the margin line coordinate using 
dev->yLineBias.  After commenting out these adjustments, the x-axis text 
is clearly shifted up (i.e. the bottom of the text is aligned at the 
specified margin line) while the y-axis text is shifted left (i.e. the 
bottom of the text is still aligned with the specified margin line).
   2) This observation lead me to realize that do_axis and do_title in 
plot.c assume padj=0 most of the time (there are exceptions depending on 
par()$las).

I'm no expert in the R code base, but the yLineBias adjustments appears 
like they might have been intended to restore symmetry -- but it only 
works for mex=1.

Is there a reason why, instead of yLineBias, we can't either:
     1) center axis and title text by default (i.e. padj=0.5)
       -or-
     2) align side=1,3 with padj=1; side=2,4 with padj=0
?


Solution 1 is trivial to implement, but this would shift positioning 
slightly relative to the current code (even for mex=1).
Solution 2 is slightly trickier because we have to pay attention to side 
and las values, but would not change the output for mex=1.


I implemented drafts of both solutions, which work at least 
superficially.  Two questions:
   -Am I missing a larger purpose to yLineBias?
   -Thoughts about which solution is better / can I contribute a patch 
to fix this?

Regards,
Philip



More information about the R-devel mailing list