[R] grid.pack and grid.frame bewilder me

cheung zihong gig798 at gmail.com
Thu Nov 10 19:00:40 CET 2011


Hello R friends,

I get quite confused in using the grid graphic function grid.pack( )
and grid.frame ( ). Here is a simple example:

 library(grid)
 grid.frame(name="frame1")
 grid.pack("frame1",rectGrob(width=unit(0.5,"npc"),
height=unit(0.5,"npc"), gp=gpar(col="red")))

what I expect is a rectangle with half the default device's
dimensions,but it returns a rectangle like 1/4 of the device.why?
In addition  wonder what the rectGrob is referred to if there are x.y arguments.

 Another question is  I want to pack several barplots of different
sizes in a row by average space,but the grid.pack just didn't work
out, which gave me  a layout that the the space between the midlines of
each figure equals,not between their bounders. I have been working on
this for  a couple of days with more confusion.

 I hope someone can help me out.  I will  greatly  appreciate it.



More information about the R-help mailing list