[R] plot/screen

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Jan 25 19:36:03 CET 2003


Luis Silva wrote:
> Dear helpers
> 
> I have this code to make 10 plots in the same device
> 
> a<-1
> split.screen(c(2:5))

You mean:
   split.screen(c(2, 5))

> for (i in 1:10){
> nova.matriz<-a*sigma+(1-a)*S
> proj<-calculo.comp(treino,nova.matriz)
> print(proj[,1:2])
> screen(i)
> plot(Re(proj[c(2,3,6,9:11,14,23),1:2]),xlim=range(c(-
> 15:15)),ylim=range(c(-5:5)),col="black")
> points(Re(proj[c(1,4:5,7:8,12:13,15:22,24:27),1:2]),col="red")
> points(Re(proj[28:38,1:2]),col="blue")
> a<-a-.1
> }
> 
> Is this the best way to do it? And I have this problem. It only 
> plots 6 screens and then gives an error
> "Error in plot.new() : Figure margins too large"
> 
> The idea is to make 10 plots being a function of parameter a. 
> It goes from 1 to zero. I've already started at zero and gone 
> to 1 but it happens the same thing.
> 
> Any hints?


What about reducing the margins (the obvious idea after reading the 
error message) or enlarging the space for the figures in another way 
(larger device region etc.)?
In order to reduce the margins, e.g. use
  ...
  screen(i)
  par(mar=c(2,2,1,1))
  ...


I think you don't need such a complex thing like split.screen().
Another way is to use
  par(mfrow=c(5, 2))
or see ?layout for a third way.


Uwe Ligges




More information about the R-help mailing list