Re: [R] (no subject)

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Wed 07 Sep 2005 - 17:35:26 EST

Salang Pan wrote:

> hiŁ¬
>
> Is it possible to draw a string text in a rectangle according the width of this rectangle? that is, the fontsize of this string text can be adjusted according the width of the rectangle.
> How to set the cex parameter in text function?
>
> text (x, y = NULL, labels = seq(along = x), adj = NULL,
> pos = NULL, offset = 0.5, vfont = NULL,
> cex = 1, col = NULL, font = NULL, xpd = NULL, ...)
>
> thanks!

The grid framework might be helpful.

For standard graphics, you can optimze the strwidth():

 plot(1:10)
 rect(1,1,9,9)
 cex <- optimize(function(x)

     abs(strwidth("Hello World", cex=x)-8),    interval=c(1, 10))$minimum
 text(5,5, "Hello World", cex=cex)

Uwe Ligges

>
>
>
>
>
> =====================================================ˇˇ
> Salang
> hypan@scbit.org
>
> Tel: 021-64363311-123
> Shanghai Center for Bioinformatics Technology
> Floor 12th,100# QinZhou Road
> Shanghai,China,200235
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
>
https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Sep 07 17:39:54 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 16:28:20 EST