Re: [R] grid and ps device (bg-color)

From: mkondrin <mkondrin_at_hppi.troitsk.ru>
Date: Wed 04 May 2005 - 00:28:08 EST

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.



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 May 04 01:05:52 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:32 EST