Gundala Viswanath <gundalav <at> gmail.com> writes:

> I have the following code that try to plot
> simple sinus curve into 2x2 grid in 1 page.
> 
> But this code of mine create 4 plots in 1 page
> each. What's wrong with my approach?
...
> library(lattice)
> library(grid)
> 
> test.plot <- function(x,y) {
>   pushViewport(viewport(layout.pos.col=x, layout.pos.row=y))
>   pushViewport(viewport(width=0.6, height=0.6));
>   plot(sin,-pi,2*pi, main= paste(c(i,j),collapse="-") )
> 
> }
> 
...         test.plot(i,j);

plot (plot.default) is "old-style" graphics and dates before grid. 
Note that your program would run without error when you remove 
the library(grid).

Use print(xyplot(..)) instead, or use par(...) to generate the
layout for your standard plots.

Dieter

______________________________________________
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.

Reply via email to