That helped. I continued to have issues with
draw.in=vplayout(2,2)$name
(I guess I still don't understand it use), but the following positions
the plot on the grid where I want it.
grid.newpage()
pushViewport(viewport(layout=grid.layout(2,2)))
vp <- vplayout(2,2)
pushViewport(vp)
print(p,newpage=FALSE)
upViewport()
The reason the ggplot instances just worked is that the ggplot2 package
is doing the viewport traversal for me in ggplot2::print.ggplot.
Thanks for the help!
Mark
On 07/12/2010 07:29 PM, Felix Andrews wrote:
The problem is that you have not pushed your viewport so it doesn't
exist in the plot. (You only pushed the layout viewport).
grid.ls(viewports = TRUE)
ROOT
GRID.VP.82
Try this:
vp<- vplayout(2,2)
pushViewport(vp)
upViewport()
grid.ls(viewports = TRUE)
#ROOT
# GRID.VP.82
# GRID.VP.86
print(p, newpage = FALSE, draw.in = vp$name)
-Felix
On 13 July 2010 01:22, Mark Connolly<wmcon...@ncsu.edu> wrote:
require("grid")
require("lattice")
fred = data.frame(x=1:5,y=runif(5))
vplayout<- function (x,y) viewport(layout.pos.row=x, layout.pos.col=y)
grid.newpage()
pushViewport(viewport(layout=grid.layout(2,2)))
p = xyplot(y~x,fred)
print( p,newpage=FALSE,draw.in=vplayout(2,2)$name)
On Mon, Jul 12, 2010 at 8:58 AM, Felix Andrews<fe...@nfrac.org> wrote:
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Yes, please, reproducible code.
On 10 July 2010 00:49, Mark Connolly<wmcon...@ncsu.edu> wrote:
I am attempting to plot a trellis object on a grid.
vplayout = viewport(layout.pos.row=x, layout.pos.col=y)
grid.newpage()
pushViewport(viewport(layout=grid.layout(2,2)))
g1 = ggplot() ...
g2 = ggplot() ...
g3 = ggplot() ...
p = xyplot() ...
# works as expected
print(g1, vp=vplayout(1,1))
print(g2, vp=vplayout(1,2))
print(g3, vp=vplayout(2,1))
# does not work
print( p,
newpage=FALSE,
draw.in=vplayout(2,2)$name)
Error in grid.Call.graphics("L_downviewport", name$name, strict) :
Viewport 'GRID.VP.112' was not found
What am I doing wrong?
Thanks!
______________________________________________
R-help@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.
--
Felix Andrews / 安福立
http://www.neurofractal.org/felix/
______________________________________________
R-help@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.