[Rd] axis, title & padj

From: Philip Johnson <plfjohnson_at_emory.edu>
Date: Wed, 02 Mar 2011 17:38:02 -0500


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:
par(mex=.1, mar=c(10,10,10,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?


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 03 Mar 2011 - 08:18:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Mar 2011 - 19:10:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive