[R] cex= and plot(), title(), mtext()

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 22 10:50:56 CET 2001


On Thu, 22 Feb 2001, Peter Perkins wrote:

> using R 1.2.1 under LinuxPPC, using the default X11 graphics device, i
> can't get the cex= argument for plot() and title() to have any effect.
> works for text(), though.  the text size for plot() and title() _is_
> correct if par(cex=size) is called first.  oddly, mtext() seems to pay
> attention to cex=, but to ignore the value set by par().

(The latter is a design feature, one that Paul Murrell is considering
changing. The default for cex in mtext is NA, not par("cex"). That is
documented on the help page.)

> for example,
>
> > plot(1:5, 1:5, main="Main", cex=2) # plots title/labels in std size

You need to use cex.main, cex.sub etc: see ?par.

> > mtext("mtext", side=1, at=1.5, line=1, cex=2) # large text here
> >
> > par(cex=2)
> > plot(1:5, 1:5, main="Main") # large text now
> > mtext("mtext", side=1, at=1.5, line=1) # but std size here
>
> i don't find this problem in the either the archives or the bug list,
> but i can't really believe that it's a bug and no one else has seen it
> yet.  so perhaps i'm speaking R with an S accent? or doing something
> else stupid?  help?

As far as plot() and title() are concerned, it works like this, I
believe.  (Also for axis().)

The global setting of cex is used to set the initial scale.
There is *additional* scaling of

main titles by cex.main
sub titles by cex.sub
axis annonation by cex.axis
xlab and ylab by cex.lab
plotted text and symbols by a cex argument.

So par(cex=2) and a local arg of cex=2 are different, deliberately.
As with many things in R graphics, I am not sure the documentation
is more than a sketch, though.


-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list