[R] splot.screen: multiple plots
Anne G
anne at wjh.harvard.edu
Mon Dec 27 11:55:29 CET 2004
I have multiple conditions that I would like to plot in a
grid. To save space, I don't need the ticks, labels etc on
the plots which are not on the outside.
I tried split.screen, but if it is clearer to use, it seems
pretty rigid since it decides of each screen size apriori
while I need more space for the left column and top or
bottom row screens than for the other plots.
axis(1,tick=FALSE) does not seem to do anything, asp=1 does
not seem to do anything either. par(pty="s") gave it a
somewhate square aspect, But there is a lot of empty space
which must have to do with margins, but setting the margins
did not seem to change anything.
I think I have seen examples like mine in a book, but it
might have been a book on Splus. Do you know where I can
find an example of what I am looking for.
thanks
Anne
----------------------------------------------------------
here is a simplified example with the same data for all
plots
X<-c(1.00000 3.63168 6.44916 10.17572 20.47440)
Y<-c(0.26 0.56 0.80 0.92 0.88)
numFreq<-7
numdist<-8
coefind <- 1
quartz(display = "", width =15, height = 10, pointsize = 9,
family = "Helvetica", antialias = TRUE,
autorefresh = TRUE)
par(pty="s")
split.screen(c(numdist,numFreq))
for (inddist in 1:numdist)
{
for (indFreq in 1:numFreq)
{
indscreen<- indFreq+(inddist-1)*numFreq
screen(indscreen)
# mar<-c(1,1,1,0)
plot(X,Y,
log="x",col="red",xlim=c(1,100),ylim=c(0,1),lab=5, xlab="",
ylab="")
axis(1,tick=FALSE)
axis(2,tick=FALSE)
if( inddist==1)
{
title(main=sprintf('Freq =
%d',indFreq));
}
if( indFreq==1)
{
axis(2, tick=TRUE)
title(ylab=sprintf('dist =
%d',inddist));
}
if (inddist==8)
{
axis(1,tick=TRUE)
title(xlab="perc face")
}
coefind <- coefind+1
}
}
close.screen(all = TRUE) # exit split-screen mode
More information about the R-help
mailing list