[R] cex option in the text function

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon Jun 25 08:33:51 CEST 2001


On Mon, 25 Jun 2001, Paul Murrell wrote:

> Hi
>
>
> > I am using the "text" function to write text on a graph and I am using the
> > cex option to specify the size of my text.  It looks like if I specify any
> > value < 0.5 the size does not change.  Anybody noticed that?  Any help?
>
>
> R can only use the fonts that are available in the system it is installed
> on.  This means that sometimes it has to use the nearest thing to what the
> user requests.
>
> On some systems, when it does not give exactly what the user asks for, it
> gives a warning.  For example, the following is a transcript of a session on
> my (UNIX/X11) system:
>
> > plot(1:10, type="n")
> > for (i in 1:10) text(i, i, "Hi There", cex=i/10)
> Warning messages:
> 1: X11 used font size 8 when 2 was requested
> 2: X11 used font size 8 when 4 was requested
> 3: X11 used font size 8 when 5 was requested
> 4: X11 used font size 8 when 6 was requested
> 5: X11 used font size 8 when 7 was requested
>
> However, notice that this warning is only given once (i.e., if I issue the
> commands again, the warnings are not repeated -- this is because the font is
> not reloaded).

Not quite.  This warning is given if the X11 driver itself altered the size
you requested by more than 10%, in an attemot to get it satisfied.
It does not check what the X11 font server actually gave you, which could
be quite different.

I don't understand why the X11 device has a lower limit of 8 (pixels, I
believe).  With anti-aliasing, text can be readable much lower.

> To further complicate things, not all devices give this warning (e.g., my
> old Windows system does not -- we should fix this if current Windows systems
> still have the problem).

No other device does the fudging....  On Windows you should have scalable
fonts (at least in the default families) and get the size you ask for. The
allowed range is 2 to 100 points (not pixels).  In practice the text seems
unreadable below about 4 points on my laptop.

> On the brighter side, this problem should only occur onscreen -- text
> scaling should come out ok in PostScript output (because it uses scalable
> fonts).

I think that it is confined to the X11 device.

-- 
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