# NOT RUN {
# gTree with two children, "red-rect" and "blue-rect" (in that order)
gt <- gTree(children=gList(
rectGrob(gp=gpar(col=NA, fill="red"),
width=.8, height=.2, name="red-rect"),
rectGrob(gp=gpar(col=NA, fill="blue"),
width=.2, height=.8, name="blue-rect")),
name="gt")
grid.newpage()
grid.draw(gt)
# Spec entire order as numeric (blue-rect, red-rect)
grid.reorder("gt", 2:1)
# Spec entire order as character
grid.reorder("gt", c("red-rect", "blue-rect"))
# Only spec the one I want behind as character
grid.reorder("gt", "blue-rect")
# Only spec the one I want in front as character
grid.reorder("gt", "blue-rect", back=FALSE)
# }
Run the code above in your browser using DataLab