[R] Problem when combining dotplot() and textplot() using grid

From: Bernhard <drunken.wallaby_at_gmail.com>
Date: Wed, 11 Jun 2008 07:40:44 +0200


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



R-help_at_r-project.org 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. Received on Wed 11 Jun 2008 - 07:11:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jun 2008 - 01:31:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive