Hello R-experts! 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. Philipp -- Dr. Philipp Pagel Tel. +49-89-3187-3675 Institute for Bioinformatics / MIPS Fax. +49-89-3187-3585 GSF - National Research Center for Environment and Health Ingolstaedter Landstrasse 1 85764 Neuherberg Germany
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
Philipp Pagel wrote:> Hello R-experts! > > 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) >I realize that this isn't what you asked for, but there is a function for staggering long axis labels in "Kickstarting R" at: http://cran.r-project.org under Contributed Documentation. Might help. Jim