[R] plot 7 * 3 matrix on DIN A4 pdf

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri May 23 10:32:09 CEST 2008



stefan.duke at gmail.com wrote:
> Hello,
> 
> I want to plot 21 scatter plots in a 7*3 matrix on a single A4 page
> (using mfcol). Below is an example, which -by and large- looks very
> close to the desired result. But I do not get it to fill out the whole
> page. If I specify the a different page size, the plots still do not
> fill out the whole page.
> Anybody an idea what to do? Maybe adjusting indvidiual plot size (if
> so, how?). Or is there a neater command to create a matrix of
> individual plots

Just specify width and height appropriately.

Uwe Ligges




> Best,
> Stefan
> 
> 
> 
> pdf(file='c:/matrix1.pdf',paper='a4',pagecentre=F)
> 
> x<-c(rnorm(mean(100,mean=50,sd=10)),rnorm(mean(100,mean=50,sd=10)))
> par(mfcol=c(7,3))
> par(pch=19)
>  par(pty="m") #"s" makes a square plot
>  par(cex=.1)
> 
>  par(cex.axis=7)
>  par(omi=c(1,1,1,1))
>  axistick<-c(0,10,20,30,40,50,60,70,80,90,100)
> par(mar=c(3, 5, 0, 0) + 0.1)
> plot(x,xlim=c(0,50),ylim=c(0,100),axes = FALSE)
> axis(2,ylab='',at=axistick)
> box(lty=1)
> plot(x,xlim=c(0,50), ylim=c(0,100),axes = FALSE)
> axis(2)
> box(lty=1)
> plot(x, xlim=c(0,50),ylim=c(0,100),axes = FALSE)
> axis(2)
> box(lty=1)
> plot(x,xlim=c(0,50), ylim=c(0,100),axes = FALSE)
> axis(2)
> box(lty=1)
> plot(x,xlim=c(0,50), ylim=c(0,100),axes = FALSE)
> axis(2)
> box(lty=1)
> plot(x,xlim=c(0,50), ylim=c(0,100),axes = FALSE)
> axis(2)
> box(lty=1)
> par(mar=c(3, 5 ,0, 0) + 0.1)
> plot(x,xlim=c(0,50), ylim=c(0,100),axes = FALSE)
> axis(2)
>  axis(1,ylab='UAS_7')
>  box(lty=1)
> 
> par(mar=c(3, 0, 0, 0) + 0.1)
> plot(as.integer(Sex),GER_TOTAL,ylim=c(0,100),xlim=c(0,3),axes = FALSE,pch=12)
> box(lty=1)
> plot(x,ylim=c(0,100),xlim=c(0,3),axes = FALSE,pch=12)
> box(lty=1)
> plot(x,ylim=c(0,100),xlim=c(0,3),axes = FALSE,pch=12)
> box(lty=1)
> plot(x,ylim=c(0,100),xlim=c(0,3),axes = FALSE)
> box(lty=1)
> plot(x,ylim=c(0,100),xlim=c(0,3),axes = FALSE,pch=12)
> box(lty=1)
> plot(x,ylim=c(0,100),xlim=c(0,3),axes = FALSE,pch=12)
> box(lty=1)
> par(mar=c(3, 0, 0, 0) + 0.1)
> plot(as.integer(Sex),GER_F6,ylim=c(0,100),xlim=c(0,3),axes = FALSE)
> axis(1,at=c(1,2),ylab='Sex')
> box(lty=1)
> 
> par(mar=c(3, 0, 0, 0) + 0.1)
> plot(x,xlim=c(0,100),ylim=c(0,100),axes = FALSE,pch=12)
> box(lty=1)
> plot(x,xlim=c(0,100), ylim=c(0,100),axes = FALSE)
> box(lty=1)
> plot(x, xlim=c(0,100),ylim=c(0,100),axes = FALSE)
> box(lty=1)
> plot(x, xlim=c(0,100),ylim=c(0,100),axes = FALSE)
> box(lty=1)
> plot(x, xlim=c(0,100),ylim=c(0,100),axes = FALSE,pch=12)
> box(lty=1)
> plot(x, xlim=c(0,100),ylim=c(0,100),axes = FALSE)
> box(lty=1)
> par(mar=c(3, 0, 0, 0) + 0.1)
> plot(x,xlim=c(0,100),ylim=c(0,100),axes = FALSE,pch=12)
> box(lty=1)
> axis(1,ylab='Sex')
> dev.off()
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list