Re: [R] grob questions

From: mkondrin <mkondrin_at_hppi.troitsk.ru>
Date: Tue 04 Oct 2005 - 00:36:36 EST

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@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.



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 Tue Oct 04 00:47:06 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:10:12 EST