Reputation: 21
I have a problem with a multipanel plots. The first one is always a little bit smaller than the others. What should I do to make it as the same size? The data is packed in this file http://1drv.ms/1SYCyhY
The plot I got is here:
This is the code I am using:
P2_TRF<-read.table("P2.txt",sep = "\t",header=F)
P3_TRF<-read.table("P3.txt",sep = "\t",header=F)
P4_TRF<-read.table("P4.txt",sep = "\t",header=F)
P5_TRF<-read.table("P5.txt",sep = "\t",header=F)
P6_TRF<-read.table("P5.txt",sep = "\t",header=F)
windows(width=20,height=5)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,10))
par(pin=c(4,3),oma=c(4,4,3,0),mar=c(0,0,0,0.5))
plot(P2_TRF$V1,P2_TRF$V2,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("0-2min",side=3,,font=2,line=-2,cex=0.8)
mtext("Intensity (a.u.)",side=2,line=2,font=2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
par(tcl= -0.5,cex=0.5)
axis(2,at=seq(0,6,by=2),las="2")
plot(P2_TRF$V3,P2_TRF$V4,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("2-4min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V5,P2_TRF$V6,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("4-6min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V7,P2_TRF$V8,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("6-8min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V9,P2_TRF$V10,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("8-10min",side=3,,font=2,line=-2,cex=0.8)
mtext("1h15m",side=3,,font=2,line=1,cex=0.8)
mtext("Time (ms)",side=1,line=3,font=2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V11,P2_TRF$V12,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("10-12min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V13,P2_TRF$V14,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("12-14min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V15,P2_TRF$V16,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("14-16min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V17,P2_TRF$V18,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("16-18min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
plot(P2_TRF$V19,P2_TRF$V20,type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext("18-20min",side=3,,font=2,line=-2,cex=0.8)
par(tcl= -0.5,cex=0.5)
axis(1,at=seq(0,10,by=2),lwd=1,lwd.ticks=1)
par(opar)
Upvotes: 1
Views: 135
Reputation: 628
You forgot about putting par(tcl= -0.5,cex=0.5)
before first plot. This option stays for rest of plots, so no need repeating it.
As a side note, avoid copy and pasting so much, and use function wrapping to avoid resetting function arguments in a same way all the time. For example
myplot <- function(x, y, mtext1, mtext2) {
plot(x, y, type="l",lwd=1.5,ann=F,
col="red",cex.axis=1.2,cex.lab=1.3,family="sans",
pch=19,axes=F, frame.plot=TRUE,xlim=c(0,11),ylim=c(0,6.5))
mtext(mtext1,side=3,,font=2,line=-2,cex=0.8)
mtext(mtext2,side=2,line=2,font=2,cex=0.8)
}
Now each plot is a one-liner, below is code for first plot.
myplot(P2_TRF$V1, P2_TRF$V2, "0-2min", "Intensity (a.u.)")
Upvotes: 1