Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gtable structure element description

Tags:

r

ggplot2

gtable

If I create a gtable and look at some of the elements, I see for instance:

test<-data.frame(x=1:20, y=21:40, facet.a=rep(c(1,2),10), facet.b=rep(c(1,2), each=20))
p <- qplot(data=test, x=x, y=y, facets=facet.b~facet.a)
# get gtable object
z <- ggplot_gtable(ggplot_build(p))
> names(z)

[1] "grobs"    "layout"   "widths"   "heights"  "respect"  "colnames" "name"    
[8] "gp"       "vp"  
    > z$widths
[1] 0.5lines            1grobwidth+0.5lines 0.620416666666666cm
[4] 1null               0.25lines           1null              
[7] 0.545041666666667cm 1lines 

Is there any detailed documentation of what the values of these elements mean with respect to the created plot? The gtable documentation only documents the functions in creating and amending gtables. The data came from a post made on July 5.

like image 311
user1879952 Avatar asked Dec 05 '12 18:12

user1879952


1 Answers

A few components are described in this wiki page. Basically,

  • grobs: list of graphical elements associated with the gtable, and to be drawn in the cells defined by the layout

  • layout: data.frame describing the position of each grob in a tabular layout

  • widths, heights: size of the rows and columns

  • respect: parameter indicating whether dimensions are linked (fixed aspect ratio)

  • colnames, name: for identification of the rows/columns

  • gp: global set of grid parameters, from which the grobs may inherit

  • vp: viewport defining where to draw the gtable on a device

like image 57
baptiste Avatar answered Sep 25 '22 16:09

baptiste