[R] Font size of axis labels
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jan 17 13:20:04 CET 2006
On Tue, 17 Jan 2006, Hilmar Berger wrote:
> In R, it is not possible to set the font size of axis labels directly
Nor of anything else, since you are limited to the fonts available on the
> Instead, scaling factors for the font chosen by the graphics
> device can be supplied. It appears that there is no constant font size
> for axis labels. My impression is that the axis label font size is
> scaled internally by R depending on the number of labels given for an axis.
Please can we have a demonstration of this: I have never seen it.
> In addition to the R-internal scaling I need to adjust the axis label
> font size for label length and the size of other elements in the same
> In order to use sensitive values for those externally supplied scaling
> factors (cex) I would like to know how R scales axis font sizes internally.
> Could someone point me to the method/file in the R-source code (R 2.1.1)
> where this scaling is done ?
I don't believe there is any scaling. And 2.1.1 is not current.
The code used is in do_axis in src/main/plot.c. The font size is selected
Rf_gpptr(dd)->cex = Rf_gpptr(dd)->cexbase * Rf_gpptr(dd)->cexaxis;
that is, just the base 'cex' multiplied by 'cex.axis' (as documented in
?axis in current R). So the target font size is
'pointsize' * 'cex' * 'cex.axis'
where the first term is set by the specific device, the second by
par("cex") and the third either via par("cex.axis") or inline from the
axis() call. Devices will produce a nearby font size in a
device-dependent fashion (both the postscript/PDF and windows families of
devices round to the nearest big point: the story for X11 is much more
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