[R] gridBase Base Plot Positioning
Dario Strbenac
D.Strbenac at garvan.org.au
Thu Apr 28 05:00:08 CEST 2011
Hello,
I'm trying to follow the documentation of how to use gridBase, and I've reached the minimal code example below as my best effort. Can someone explain how to keep the column of boxplots on the same page as the rectangles (even though I've tried new = TRUE) ? Also, would it be hard / possible to match up the middle of each boxplot to the middle of each rectangle ?
pdf("tmp.pdf", h = 6, w = 10)
pushViewport(plotViewport(c(5, 5, 4, 2)))
pushViewport(viewport(layout = grid.layout(4, 6)))
for(i in 1:5)
{
for(i2 in 1:4)
{
pushViewport(viewport(layout.pos.row = i2, layout.pos.col = i))
grid.rect()
popViewport()
}
}
pushViewport(viewport(layout.pos.col = 6))
plot.new()
par(plt = gridPLT(), new = TRUE)
randData <- lapply(1:4, function(x) sample(10, 10, TRUE))
boxplot(randData, horizontal = TRUE)
dev.off()
I'm using gridBase_0.4-3.
Thanks,
Dario.
--------------------------------------
Dario Strbenac
Research Assistant
Cancer Epigenetics
Garvan Institute of Medical Research
Darlinghurst NSW 2010
Australia
More information about the R-help
mailing list