[R] Axis labels

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 16 10:33:27 CEST 2003


On Fri, 16 May 2003, Philipp Pagel wrote:

> When I produce a plot R takes avoids overlapping axis labels in order to
> maintain readabilty which is great. But now I have written a little
> custom plot function in which I set my own labels and label
> positions after generating the actual plot:
> 
> axis(..., lables=c('A', 'B', 'F', 'G', 'M'), at=mypositions)
> 
> As you may have guessed: This is categorial data. But the labels (and
> categories) are unevenly spaced. I need to make sure, that all labels
> are printed. Is there a way to tell R not to care about overlapping
> labels or even better automatically reduce font size or scale the plot
> to make everything fit? In my actual example letters would'n really
> overlap - just get pretty close, so simply switching off this "distance
> check" would solve my problem. 
> 
> I have read ?axis and ?par but couldn't find anything that seems to help.
> 
> Thanks for any hints.

I think you would prefer to use text() (you'll need to make sure xpd is
set suitably) or even mtext() to label your axis.  AFAIR the overlap check
is deep in the axis C code.  You could also call axis() repeatedly, one 
label at a time.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list