[R] Problem when combining dotplot() and textplot() using grid
Bernhard
drunken.wallaby at gmail.com
Wed Jun 11 07:40:44 CEST 2008
Hi everyone.
I want to solve the following problem. I have a data.frame and I
create a dotplot using lattice.
Then I want to use the grid-package to create a combined graphic which
contains the dotplot as well as a textplot() (using package gplots) of
the data.frame next to the dotplot.
Example code:
library(lattice)
library(grid)
library(gplots)
xx <- data.frame(f=factor(rep(1:5, each=5)), gr= rep(c("gr1", "gr2",
"gr3", "gr4", "gr5"), 5), val=rnorm(25))
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))
pushViewport(viewport(layout.pos.col=1, layout.pos.row=1))
p <- dotplot(f ~ val, groups=gr, xx, cex=1.7, pch=20)
print(p, newpage=FALSE)
popViewport(1)
pushViewport(viewport(layout.pos.col=2, layout.pos.row=1))
textplot(xx, show.rownames=FALSE)
popViewport(1)
Obviously, this does not work since textplot() seems to call plot.new
no matter what options are set with par().
My question: Is it possible to archieve my goal to plot the data.frame
with textplot() next to the dotplot?
And furthermore, if it is possible to do so, is it even possible to
adjust the textplot in a way that the each row of the data.frame when
plotted using textplot() is at the same height than the corresponding
row in the dotplot? I guess that this is quite tricky and any hint on
which package or functions I could use would be very helpful.
Thank you very much.
Bernhard
More information about the R-help
mailing list