我正在尝试使用R生成pdf中的一些图形。我没有得到任何警告或错误,但我的图表没有生成,我没有使用其他人遇到类似的一些软件包的问题。我的代码如下。起初我重新排列了我的数据向量,想出了一个矩阵,把它变成了一个数据框(我想这就是问题所在,但是我找不到它)然后我会生成我的图。
SWCvec<-matrix(data=c(38,30.8,33.4,27.3,23.1,34.3,16.4,11.3,
14.8,27.7,23.1,36.1,10.5,8.3,10.4,30.4,30.2,36.2,8,5.2,7.3,
27.1,19.9,28.7,6.1,2.5,5.1,20.7,18.9,31.5),ncol=6,byrow=TRUE)
SWCdata<-data.frame(S1=SWCvec[,1],S2=SWCvec[,2],S3=SWCvec[,3],S4=SWCvec[,4],S5=SWCvec[,5],S6=SWCvec[,6])
SWC1<-c(SWCdata$S1,SWCdata$S2,SWCdata$S3)
SWC2<-c(SWCdata$S4,SWCdata$S5,SWCdata$S6)
Lpsivec<-matrix(data=c(-0.45,-0.5,-0.5,-0.6,-0.5,-0.65,-0.8,-0.85,-0.85,-0.65,-0.5,-0.45,-1.15,-1.2,-1.1,-0.65,-0.5,-0.9,-1.25,-1.65,-1.15,-0.65,-0.55,-0.65,-1.25,-1.65,-1.4,-0.75,-0.55,-0.65),ncol=6,byrow=TRUE)
Lpsidata<-data.frame(L1=Lpsivec[,1],L2=Lpsivec[,2],L3=Lpsivec[,3],L4=Lpsivec[,4],L5=Lpsivec[,5],L6=Lpsivec[,6])
Lpsi1<-c(Lpsidata$L1,Lpsidata$L2,Lpsidata$L3)
Lpsi2<-c(Lpsidata$L4,Lpsidata$L5,Lpsidata$L6)
Pnvec<-matrix(data=c(3.885,8.615,5.7,5.62,4.84,6.84,1.065,4.035,4.485,7.245,7.815,7.435,0.3795,0.655,1.325,2.985,6.425,5.63,0.473,2.125,1.335,5.62,7.455,6.48,0.386,1.329,1.17,6.6,6.125,10.3),ncol=6,byrow=TRUE)
Pndata<-data.frame(P1=Pnvec[,1],P2=Pnvec[,2],P3=Pnvec[,3],P4=Pnvec[,4],P5=Pnvec[,5],P6=Pnvec[,6])
Pn1<-c(Pndata$P1,Pndata$P2,Pndata$P3)
Pn2<-c(Pndata$P4,Pndata$P5,Pndata$P6)
GWvec<-matrix(data=c(0.038,0.122,0.054,0.06,0.062,0.093,0.00575,0.0366,0.03355,0.099,0.14095,0.135,0.00755,0.01485,0.0138,0.046,0.079,0.07055,0.00705,0.0164,0.01455,0.08555,0.21,0.1455,0.00815,0.01545,0.0141,0.1285,0.245,0.261),ncol=6,byrow=TRUE)
GWdata<-data.frame(G1=GWvec[,1],G2=GWvec[,2],G3=GWvec[,3],G4=GWvec[,4],G5=GWvec[,5],G6=GWvec[,6])
GW1<-c(GWdata$G1,GWdata$G2,GWdata$G3)
GW2<-c(GWdata$G4,GWdata$G5,GWdata$G6)
WUEvec<-matrix(data=c(102.2368421,70.6147541,105.5555556,93.66666667,78.06451613,73.5483871,185.2173913,110.2459016,133.681073,73.18181818,55.44519333,55.07407407,50.26490066,44.10774411,96.01449275,64.89130435,81.32911392,79.80155918,67.09219858,129.5731707,91.75257732,65.69257744,35.5,44.53608247,47.36196319,86.01941748,82.9787234,51.3618677,25,39.46360153),ncol=6,byrow=TRUE)
WUEdata<-data.frame(W1=WUEvec[,1],W2=WUEvec[,2],W3=WUEvec[,3],W4=WUEvec[,4],W5=WUEvec[,5],W6=WUEvec[,6])
WUE1<-c(WUEdata$W1,WUEdata$W2,WUEdata$W3)
WUE2<-c(WUEdata$W4,WUEdata$W5,WUEdata$W6)
A<-c(Lpsi1, Lpsi2, SWC1, SWC2, Pn1, Pn2, GW1, GW2, WUE1, WUE2)
Amat<-matrix(data=A,nrow=30,byrow=FALSE)
Amat
V0<-c(rep(0, each=15))
V1<-c(rep(1, each=15))
V2<-c(V0,V1)
Y<-cbind(Amat,V2)
Xdata<-data.frame(Lpsi=Y[,1], SWC=Y[,2], Pn=Y[,3], GW=Y[,4], WUE=Y[,5], Treatment=Y[,6])
pdf("P2Graph.pdf")
plot(Xdata$SWC, Xdata$Lpsi, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Leaf Water Potential versus Soil Water Content",xlab='Soil Water Content', ylab='Leaf Water Potential')
plot(Xdata$SWC, Xdata$Pn, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Net Photosynthetic Rate versus Soil Water Content",xlab='Soil Water Content', ylab='Net Photosynthetic Rate')
plot(Xdata$SWC, Xdata$GW, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Stomatal Conductance versus Soil Water Content",xlab='Soil Water Content', ylab='Stomatal Conductance')
plot(Xdata$SWC, Xdata$WUE, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Instantaneous Water Use Efficiency versus Soil Water Content",xlab='Soil Water Content', ylab='Instantaneous Water Use Efficiency')
plot(Xdata$Lpsi, Xdata$Pn, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Net Photosynthetic Rate versus Leaf Water Potential",xlab='Leaf Water Potential', ylab='Net Photosynthetic Rate')
plot(Xdata$Lpsi, Xdata$GW, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Stomatal Conductance versus Leaf Water Potential",xlab='Leaf Water Potential', ylab='Stomatal Conductance')
plot(Xdata$GW, Xdata$Pn, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Net Photosynthetic Rate versus Stomatal Conductance",xlab='Stomatal Conductance', ylab='Net Photosynthetic Rate')
plot(Xdata$Lpsi, Xdata$WUE, col=Xdata$Treatment+1, pch=Xdata$Treatment+3,main="Intrinsic Water Use Efficiency versus Leaf Water Potential",xlab='Leaf Water Potential', ylab='Intrinsic Water Use Efficiency')
pdf()
答案 0 :(得分:2)
您没有关闭地块到设备的通话。终止pdf
调用的方法是dev.off()
,而pdf()
没有参数。 (是的,我知道它与sink(文件)不一致... sink()但我没有写语言。我也没有写?Devices
页面,我认为应该更完整关闭设备电话。见:
?Devices
?dev.off()