[R] grid and ps device (bg-color)
mkondrin
mkondrin at hppi.troitsk.ru
Tue May 3 16:28:08 CEST 2005
Hi!
>
>
> grid.rect(width=2, height=2,
> gp=gpar(fill=ps.options()$bg.color))
>
Yes, it works (more or less), but the best is to use
grid.rect(width=unit(1,"npc")+unit(0.5,"inches"),...)
as postscript device leaves a 0.25-inch frame around the page.
BTW wouldn't you fix a bug with the determination of "strwidth" in the
code like this:
l<-c("1","23","456","7890")
unit(1,"strwidth",l)
The last command calculates the width of the first element of l, which
is not the thing one would like to have. The best would be the
calculation of maximum length of vector's elements (a simple for-cycle
in unit.c). It also solves the problems with
t<-grid.text(l,y=c(0.9,0.8,0.7,0.6))
unit(1,"grobwidth",t)
where the desired answer should be the length of the longest string in l
(in R-2.0.1 this returns the length of the l[[0]] too).
I have fixed it in my R installation but the patch is obvious.
Thank you.
More information about the R-help
mailing list