【发布时间】:2015-06-04 16:44:52
【问题描述】:
我对多面板图有疑问。第一个总是比其他的小一点。我应该怎么做才能使其大小相同? 数据打包在这个文件中 http://1drv.ms/1SYCyhY
我得到的情节在这里:
这是我正在使用的代码:
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)
【问题讨论】:
-
问题是由于y轴标签和刻度占用的空间。基础图形中有一些变通方法,但你反对 ggplot 吗?它很容易处理这样的事情(尽管我们需要先转换一下您的数据)。
-
ggplot 会是一个很好的学习方法。我读了一点。但是我刚刚开始学习 R。所以,我以后可能会看看它。无论如何,非常感谢您的时间和精力。