[R] grob questions

mkondrin mkondrin at hppi.troitsk.ru
Mon Oct 3 16:36:36 CEST 2005


Gabor Grothendieck wrote:

>If I run the following example from:
>http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
>
>  
>
>>grid.newpage()
>>pushViewport(viewport(w = 0.5, h = 0.5))
>>myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
>>    
>>
>+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
>  
>
>>grid.draw(myplot)
>>grid.edit("myplot::xaxis", at = 1:10/11)
>>grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
>>grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
>>    
>>
>
>then
>
>  
>
>>str(myplot$children$xaxis)
>>    
>>
>
>lists 'at' but not the 'labels'.
>
>yet if I do this then the labels are listed:
>
>  
>
>>xx <- xaxisGrob(name = "myX", at = 1:10)
>>childNames(xx)
>>    
>>
>[1] "major"  "ticks"  "labels"
>
>
>1. How do I get to labels in the first case?
>
>2. Is there a better construct than myplot$children$xaxis?
>
>Thanks.
>
>______________________________________________
>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
>  
>
grid.get("myplot::xaxis::labels")$label

or

grid.get("myplot::xaxis")$children$labels$label

R-object representing grob in R (in your case this is - myplot) is not 
dynamic you have to update it with grid.get. The argument is the name of 
the grob.




More information about the R-help mailing list