> Here's a partial extract from a sample session after running your code > (NOTE this is using the development version of R; grid.ls() does not > exist in R 2.5.1 or earlier): > > Inspect the grob tree with grid.ls() (similar to Hadley's > current.grobTree(), but with different formatting) ...
(I'll probably remove current.grobTree as soon as grid.ls makes it to a released version of R) > > > grid.ls() > plot-surrounds > GRID.cellGrob.118 > background > GRID.cellGrob.119 > plot.gTree.113 > background > guide.gTree.90 > background.rect.80 > minor-horizontal.segments.82 > minor-vertical.segments.84 > # OUTPUT TRUNCATED The format is much nicer than mine! > ... It is not necessarily obvious which grob is which, > but a little trial and error (e.g., grid.edit() to change > the colour of a grob) shows that the border on the first > panel is 'guide.rect.92', which is a child of 'plot.gTree.113' > (NOTE the numbers come from a fresh R session). I will try and rename these grobs so that they are more easily accessible (and reproducible across multiple calls). That should make things easier in the future. > Use grid.get() to grab that gTree and inspect that > further using grid.ls(), this time also showing the > viewports involved ... What do all the upViewports represent? Could the downViewports be incorporating into the same place as the original definition? > (The remaining code should work for you in your version of R; it > is just grid.ls() that is new.) > > Remove the original border rect, ... > > > grid.remove("guide.rect.92", global=TRUE) > > ... (need global=TRUE because the border appears twice as a child > of 'plot.gTree.113' [not sure why that is]) then add some lines that > only draw the top, right, and bottom borders ... > > > grid.add("plot.gTree.113", > linesGrob(c(0, 1, 1, 0), c(1, 1, 0, 0), > gp=gpar(col="green"), > vp=vpPath("layout", "panel_1_1"))) > > ... (I drew the new lines green so that they are easy to see). > NOTE that in order to put the new lines in the same "place" as > the original border, the new lines are added as children of the > gTree 'plot.gTree.113' and they have a vpPath to make sure > they get drawn in the right viewport within that gTree. Do you think it would be worth drawing all these rectangles as lines to make them easier to edit? > What would probably be ideal would be a graphical interface to the > grid.ls()-type information (something like an object explorer) that > would make it easier to see which object is which and also make it > easier to add and remove objects. A nice student project perhaps :) That would be great! Hadley -- http://had.co.nz/ ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.