[R-sig-Geo] no plots into viewport

Roger Bivand Roger.Bivand at nhh.no
Wed May 2 14:01:22 CEST 2007


On 2 May 2007, Michal Gallay wrote:

> Dear R Users,
> 
> could anyone help me and explain why no plot with 'plot'function is plotted 
> in the viewport, but as a single plot on the next page?
> 
> grid.text() works, but neither xyplot() nor plot() do.
> 
> library(graphics)
> library(grid)
> library(lattice)
> 
> top.vp <- viewport(layout = grid.layout(1,2))
> vp.plot1 <- viewport(layout.pos.col=1,layout.pos.row=1, name="vp.plot1")
> vp.plot2 <- viewport(layout.pos.col=2,layout.pos.row=1, name="vp.plot2")
> splot <- vpTree(top.vp, vpList(vp.plot1, vp.plot2))
> 
> pushViewport(splot)
> seekViewport("vp.plot1")
> grid.text("plot1 should be here")
> plot <- xyplot(1:10~1:10)
> print(plot)
> 
> Thank you very much for advice.

Since the density of experienced lattice graphics users on this list 
doesn't seem to be high - you didn't get any reply to your similarly 
careful question a couple of days ago - perhaps you should ask on the R 
help list? I see that:

pushViewport(splot)
seekViewport("vp.plot1")
grid.text("plot1 should be here")
seekViewport("vp.plot2")
grid.text("plot2 should be here")

seems to put the device into two-column mode, but xyplot over-rides the 
viewport set-up.

Roger

> 
> Michal
> 
> 
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list