[R] (no subject)
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Sep 7 09:35:26 CEST 2005
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 at scbit.org
>
> Tel: 021-64363311-123
> Shanghai Center for Bioinformatics Technology
> Floor 12th,100# QinZhou Road
> Shanghai,China,200235
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at 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
More information about the R-help
mailing list